Use find_spec() in meta importer

The `find_module()` method of meta importers has been deprecated for a
long time. Python 3.12 no longer falls back to `find_module()`.

See: https://docs.python.org/3.12/whatsnew/3.12.html#removed
Related: https://pagure.io/freeipa/issue/9437
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abbra@users.noreply.github.com>
This commit is contained in:
Christian Heimes 2023-09-01 12:11:35 +02:00 committed by Florence Blanc-Renaud
parent 32721c4132
commit 7ddf7711f3

View File

@ -21,10 +21,11 @@ class IpaMetaImporter:
def __init__(self, platform):
self.platform = platform
def find_module(self, fullname, path=None):
def find_spec(self, fullname, path=None, target=None):
"""Meta importer hook"""
if fullname in self.modules:
return self
module = self.load_module(fullname)
return module.__spec__
return None
def load_module(self, fullname):