Skip to content

Commit

Permalink
Use find_spec() in meta importer
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Alexander Bokovoy <[email protected]>
  • Loading branch information
tiran authored and flo-renaud committed Sep 18, 2023
1 parent 32721c4 commit 7ddf771
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ipaplatform/_importhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7ddf771

Please sign in to comment.