mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
[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 9e2be60634
)
This commit is contained in:
parent
3c193cf8af
commit
a09bb87c1e
7 changed files with 654 additions and 616 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue