New submission from Gregory P. Smith: If you are
1) using zipimport 2) zipimport.c has cached the zip file's central index during an import. 3) the .zip file is modified or replaced while the process is running 4) you try to import something new from that .zip file. you're gonna have a bad time... Typically a ZipImportError or some other form of ImportError. What happen's is that Modules/zipimport.c is caching the end-of-zipfile central index for the .zip file and reusing that data on subsequent imports from that .zip without either (a) keeping the file handle open or (b) confirming that the .zip file has not changed. I doubt many users are running into this. But one situation where you do is when you zip up the Python standard library for your installed python and a long running process encounters data using a different encoding which triggers an import of an encodings.foo module after another process has come along and upgraded the standard library .zip file as part of updating your python installation... I've got a fix in the works. Test attached. For the fix I am going with option (b) to reconfirm the validity of the .zip file any time something is imported from it rather than option (a) as leaving a new file handle open for the duration of the process, while the _correct ideal design_ seems intrusive for stable bug fix release. I have only confirmed the bug on Python 2.7 & 3.3; i'll test default (3.4) after working on those two. ---------- assignee: gregory.p.smith files: zipimport_modify_zip_test.patch keywords: patch messages: 198351 nosy: gregory.p.smith priority: normal severity: normal status: open title: zipimport behaves badly when the zip file changes while the process is running type: behavior versions: Python 2.7, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file31854/zipimport_modify_zip_test.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19081> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com