Skip to content

Commit

Permalink
Implement find_spec() for _SixMetaPathImporter. (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon authored Apr 4, 2021
1 parent 42636b1 commit 2591629
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions six.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ 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 +191,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

0 comments on commit 2591629

Please sign in to comment.