diff options
| author | Brett Cannon <brett@python.org> | 2012-08-10 16:21:12 (GMT) |
|---|---|---|
| committer | Brett Cannon <brett@python.org> | 2012-08-10 16:21:12 (GMT) |
| commit | f4dc9204cc406ab41c2d643c1a64375a6a2954e5 (patch) | |
| tree | c0cf92198b707bac6a68b801305ad86b24eb814f /Lib/importlib/_bootstrap.py | |
| parent | 2d6266d5f148549979df024459e29b73307b86c4 (diff) | |
| download | cpython-f4dc9204cc406ab41c2d643c1a64375a6a2954e5.zip cpython-f4dc9204cc406ab41c2d643c1a64375a6a2954e5.tar.gz cpython-f4dc9204cc406ab41c2d643c1a64375a6a2954e5.tar.bz2 | |
Issue #15502: Finish bringing importlib.abc in line with the current
state of the import system. Also make importlib.invalidate_caches()
work with sys.meta_path instead of sys.path_importer_cache to
completely separate the path-based import system from the overall
import system.
Patch by Eric Snow.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
| -rw-r--r-- | Lib/importlib/_bootstrap.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 4f61a5b..7b12ab0 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1186,6 +1186,14 @@ class PathFinder: """Meta path finder for sys.path and package __path__ attributes.""" @classmethod + def invalidate_caches(cls): + """Call the invalidate_caches() method on all path entry finders + stored in sys.path_importer_caches (where implemented).""" + for finder in sys.path_importer_cache.values(): + if hasattr(finder, 'invalidate_caches'): + finder.invalidate_caches() + + @classmethod def _path_hooks(cls, path): """Search sequence of hooks for a finder for 'path'. @@ -1235,14 +1243,14 @@ class PathFinder: portions = [] if loader is not None: # We found a loader: return it immediately. - return (loader, namespace_path) + return loader, namespace_path # This is possibly part of a namespace package. # Remember these path entries (if any) for when we # create a namespace package, and continue iterating # on path. namespace_path.extend(portions) else: - return (None, namespace_path) + return None, namespace_path @classmethod def find_module(cls, fullname, path=None): |
