diff options
author | Brett Cannon <brettcannon@users.noreply.github.com> | 2018-04-07 00:02:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-07 00:02:18 (GMT) |
commit | a09bb87c1eebb07b01b8105cf536704893aec565 (patch) | |
tree | 1b2003bef18312f6230a13e93acec7a5047d19a4 /Lib/importlib/_bootstrap_external.py | |
parent | 3c193cf8afce525b1283986f113de0e16f23e115 (diff) | |
download | cpython-a09bb87c1eebb07b01b8105cf536704893aec565.zip cpython-a09bb87c1eebb07b01b8105cf536704893aec565.tar.gz cpython-a09bb87c1eebb07b01b8105cf536704893aec565.tar.bz2 |
[3.7] bpo-33169: Remove values of `None` from sys.path_importer_cache when invalidating caches (GH-6402) (GH-6403)
An entry of None in sys.path_importer_cache represents a negative/missing finder for a path, so clearing it out makes sense.
(cherry picked from commit 9e2be60634914f23db2ae5624e4acc9335bf5fea)
Diffstat (limited to 'Lib/importlib/_bootstrap_external.py')
-rw-r--r-- | Lib/importlib/_bootstrap_external.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index e295174..490f20d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -1179,8 +1179,10 @@ class PathFinder: 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'): + for name, finder in list(sys.path_importer_cache.items()): + if finder is None: + del sys.path_importer_cache[name] + elif hasattr(finder, 'invalidate_caches'): finder.invalidate_caches() @classmethod |