diff options
author | Brett Cannon <brett@python.org> | 2021-04-04 15:25:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 17:25:03 -0500 |
commit | 25916292d96f5f09a43d6736a5152348212727b5 (patch) | |
tree | 1b68f8598fa6ce799b59cbdbd9a7763113101253 | |
parent | 42636b15dd1a5b85de56eac98e47954d4c776576 (diff) | |
download | six-git-25916292d96f5f09a43d6736a5152348212727b5.tar.gz |
Implement find_spec() for _SixMetaPathImporter. (#352)
-rw-r--r-- | six.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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] |