Skip to content

Commit

Permalink
Implement MetaPathFinder.find_spec method in MyFinder subclass.
Browse files Browse the repository at this point in the history
The `MyFinder` subclass of [`MetaPathFinder`](https://docs.python.org/3.11/library/importlib.html#importlib.abc.MetaPathFinder) currently only implements the deprecated `find_module` method. That deprecated method was [removed](python/cpython#98059) in Python 3.12. This change adds an implementation for its replacement method called `find_spec`.
  • Loading branch information
fumoboy007 authored Sep 16, 2024
1 parent 33f306e commit e97431c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/helpers/generator3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ def find_module(self, fullname, path=None):
imported_names.add(fullname)
return None

# noinspection PyMethodMayBeStatic
def find_spec(self, fullname, path, target=None):
imported_names.add(fullname)
return None

my_finder = MyFinder()
sys.meta_path.insert(0, my_finder)
try:
Expand Down

0 comments on commit e97431c

Please sign in to comment.