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.

classification
Title: zipfile leaves a file handle open if file is zero size
Type: crash Stage:
Components: Windows Versions: Python 2.6
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, brian.curtin, r.david.murray, ryles, skelker
Priority: normal Keywords:

Created on 2009-10-19 13:33 by skelker, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zipfileCrash.py skelker, 2009-10-19 13:33 The attached script replicates the issue for me.
Messages (8)
msg94236 - (view) Author: (skelker) Date: 2009-10-19 13:33
I noticed today if I attempt to create a ZipFile object for read access,
and the zip file is zero bytes, the ZipFile object throws an exception,
but there is still an open handle to the file.  So if I catch that
exception, and then try to delete the file, the delete then fails.  I
have attached a script that replicates the issue.
msg94482 - (view) Author: Ryan Leslie (ryles) Date: 2009-10-26 09:18
I expect this should already be fixed by the commit in
http://bugs.python.org/issue6511

BadZipFile will now be raised for empty files rather than IOError, and
so ZipFile._GetContents() should now also close the file.

The fix was committed to trunk, but I don't see it merged into 2.6.
msg94486 - (view) Author: (skelker) Date: 2009-10-26 12:42
Thanks.  I did do a search before opening my ticket.  Not sure why I didn't see that in my search. Sorry for the duplicate ticket.

Steve Kelker
(952)882-4381 (or x4381)
msg94487 - (view) Author: (skelker) Date: 2009-10-26 12:43
Fixed in http://bugs.python.org/issue6511
msg94629 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2009-10-28 14:19
Since the issue exists in 2.6 and is only currently fixed on trunk and
beyond, shouldn't the 6511 fix make it's way backwards into 2.6.x?
msg94630 - (view) Author: (skelker) Date: 2009-10-28 14:37
That would be great.  Perhaps that should be discussed in 6511.  I'll make a note there.

Steve Kelker
(952)882-4381 (or x4381)
msg94635 - (view) Author: Ryan Leslie (ryles) Date: 2009-10-28 18:02
Yes, I think this fix should have been included in the 2.6 branch. I
subscribed Amaury to look into that when I last updated.
msg94636 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-28 19:19
The 2.6 branch was frozen except for critical issues during the release
process for 2.6.3 and then 2.6.4.  Now that 2.6.4 is out, the bug fix
can be backported.
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51418
2009-10-28 19:19:36r.david.murraysetnosy: + r.david.murray
messages: + msg94636
2009-10-28 18:02:24rylessetmessages: + msg94635
2009-10-28 14:37:03skelkersetmessages: + msg94630
2009-10-28 14:19:35brian.curtinsetnosy: + brian.curtin
messages: + msg94629
2009-10-26 12:43:52skelkersetstatus: open -> closed

messages: + msg94487
2009-10-26 12:42:29skelkersetmessages: + msg94486
2009-10-26 09:18:56rylessetnosy: + amaury.forgeotdarc, ryles
messages: + msg94482
2009-10-19 13:33:47skelkercreate