Ronald Oussoren <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com