This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients brett.cannon, pablogsal, ronaldoussoren, twouters
Date 2021-09-16.10:44:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631789075.22.0.851092270097.issue45183@roundup.psfhosted.org>
In-reply-to
Content
I just noticed that I'm unnecessarily obtuse in my description of a possible fix, the diff (without test update):

% git diff Lib/zipimport.py                                                                                        (main)cpython
diff --git a/Lib/zipimport.py b/Lib/zipimport.py
index c55fec6aa1..43ac6cbe57 100644
--- a/Lib/zipimport.py
+++ b/Lib/zipimport.py
@@ -334,7 +334,7 @@ def invalidate_caches(self):
             _zip_directory_cache[self.archive] = self._files
         except ZipImportError:
             _zip_directory_cache.pop(self.archive, None)
-            self._files = None
+            self._files = {}
 
 
     def __repr__(self):


With that change the exception should not happen, and the now stale zipimporter would be ignored when flushing the cache while the zipfile referenced by the zip importer instance has been removed.

That said, I haven't tested this and won't create a PR because my local tree is (still) a mess.
History
Date User Action Args
2021-09-16 10:44:35ronaldoussorensetrecipients: + ronaldoussoren, twouters, brett.cannon, pablogsal
2021-09-16 10:44:35ronaldoussorensetmessageid: <1631789075.22.0.851092270097.issue45183@roundup.psfhosted.org>
2021-09-16 10:44:35ronaldoussorenlinkissue45183 messages
2021-09-16 10:44:35ronaldoussorencreate