summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2021-04-04 15:25:03 -0700
committerGitHub <noreply@github.com>2021-04-04 17:25:03 -0500
commit25916292d96f5f09a43d6736a5152348212727b5 (patch)
tree1b68f8598fa6ce799b59cbdbd9a7763113101253
parent42636b15dd1a5b85de56eac98e47954d4c776576 (diff)
downloadsix-git-25916292d96f5f09a43d6736a5152348212727b5.tar.gz
Implement find_spec() for _SixMetaPathImporter. (#352)
-rw-r--r--six.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/six.py b/six.py
index d162d09..5e7f0ce 100644
--- a/six.py
+++ b/six.py
@@ -71,6 +71,11 @@ else:
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."""
@@ -186,6 +191,11 @@ class _SixMetaPathImporter(object):
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]