bpo-33169: Remove values of None from sys.path_importer_cache when invalidating caches (GH-6402)

An entry of None in sys.path_importer_cache represents a negative/missing finder for a path, so clearing it out makes sense.
This commit is contained in:
Brett Cannon 2018-04-06 16:10:18 -07:00 committed by GitHub
parent 3a9ccee0e5
commit 9e2be60634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 652 additions and 620 deletions

View file

@ -406,7 +406,7 @@ class InvalidateCacheTests:
# There should be no issues if the method is not defined.
key = 'gobbledeegook'
sys.path_importer_cache[key] = None
self.addCleanup(lambda: sys.path_importer_cache.__delitem__(key))
self.addCleanup(lambda: sys.path_importer_cache.pop(key, None))
self.init.invalidate_caches() # Shouldn't trigger an exception.