From e97431cd7d602352580f966a4d9552c2fd052ee4 Mon Sep 17 00:00:00 2001 From: fumoboy007 <2100868+fumoboy007@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:37:48 -0700 Subject: [PATCH] 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](https://github.com/python/cpython/pull/98059) in Python 3.12. This change adds an implementation for its replacement method called `find_spec`. --- python/helpers/generator3/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/helpers/generator3/core.py b/python/helpers/generator3/core.py index ab0e11a6877f9..f828dc1d1017c 100644 --- a/python/helpers/generator3/core.py +++ b/python/helpers/generator3/core.py @@ -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: