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 gregory.p.smith
Recipients gregory.p.smith
Date 2013-09-24.04:00:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1379995203.41.0.89812771706.issue19081@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-09-24 04:00:03gregory.p.smithsetrecipients: + gregory.p.smith
2013-09-24 04:00:03gregory.p.smithsetmessageid: <1379995203.41.0.89812771706.issue19081@psf.upfronthosting.co.za>
2013-09-24 04:00:03gregory.p.smithlinkissue19081 messages
2013-09-24 04:00:02gregory.p.smithcreate