Skip to content

Commit

Permalink
Merge pull request #670 from pushkarnk/fix-669
Browse files Browse the repository at this point in the history
Move _SixMetaPathImporter to using find_spec()
  • Loading branch information
mikolmogorov authored Aug 27, 2024
2 parents b0efd48 + 441b1c6 commit 81656fc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flye/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def __len__(self):
MAXSIZE = int((1 << 63) - 1)
del X

if PY34:
from importlib.util import spec_from_loader
else:
spec_from_loader = None

def _add_doc(func, doc):
"""Add documentation to a function."""
Expand Down Expand Up @@ -186,6 +190,11 @@ def find_module(self, fullname, path=None):
return self
return None

def find_spec(self, fullname, path, target=None):
if fullname in self.known_modules:
return spec_from_loader(fullname, self)
return None

def __get_module(self, fullname):
try:
return self.known_modules[fullname]
Expand Down Expand Up @@ -223,6 +232,12 @@ def get_code(self, fullname):
return None
get_source = get_code # same as get_code

def create_module(self, spec):
return self.load_module(spec.name)

def exec_module(self, module):
pass

_importer = _SixMetaPathImporter(__name__)


Expand Down

0 comments on commit 81656fc

Please sign in to comment.