From 9e2be60634914f23db2ae5624e4acc9335bf5fea Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 6 Apr 2018 16:10:18 -0700 Subject: 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. --- Lib/test/test_importlib/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/test_importlib/test_api.py') diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py index 8beb4244ea..edb745c2cd 100644 --- a/Lib/test/test_importlib/test_api.py +++ b/Lib/test/test_importlib/test_api.py @@ -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. -- cgit v1.2.1