Skip to content

Commit e97431c

Browse files
authored
Implement MetaPathFinder.find_spec method in MyFinder subclass.
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`.
1 parent 33f306e commit e97431c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/helpers/generator3/core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ def find_module(self, fullname, path=None):
592592
imported_names.add(fullname)
593593
return None
594594

595+
# noinspection PyMethodMayBeStatic
596+
def find_spec(self, fullname, path, target=None):
597+
imported_names.add(fullname)
598+
return None
599+
595600
my_finder = MyFinder()
596601
sys.meta_path.insert(0, my_finder)
597602
try:

0 commit comments

Comments
 (0)