classification
Title: zipfile: Invalid argument when opening zero-sized files
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, r.david.murray, skelker, srid
Priority: normal Keywords:

Created on 2009-07-18 03:05 by srid, last changed 2010-01-06 20:16 by r.david.murray. This issue is now closed.

Messages (8)
msg90653 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-07-18 03:05
Ideally, zipfile.BadZipFile should be thrown when trying to open files 
that are zero-sized.

sridharr@whymac:/tmp/i > apy -c "import zipfile; zipfile.ZipFile
('empty.zip').extractall()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
zipfile.py", line 693, in __init__
    self._GetContents()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
zipfile.py", line 713, in _GetContents
    self._RealGetContents()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
zipfile.py", line 723, in _RealGetContents
    endrec = _EndRecData(fp)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
zipfile.py", line 189, in _EndRecData
    fpin.seek(-sizeEndCentDir, 2)
IOError: [Errno 22] Invalid argument
sridharr@whymac:/tmp/i >
msg90654 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-07-18 03:05
Also repros on python-3.1
msg90655 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-07-18 03:06
Note: empty.zip is nothing but an empty file created using the 'touch' 
command.
msg91019 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-28 22:20
Fixed in r74245. Thanks for the report!
msg91021 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-07-28 22:36
Amaury, shouldn't this also be merged to the py3k branch? (I am not 
aware of any Python commit policies so just asking)
msg91029 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-29 06:32
Oh, this was done with r74246, I just forgot to mention it.
Anyway all changes in trunk are regularly merged into py3k.
msg94631 - (view) Author: (skelker) Date: 2009-10-28 14:38
Is this going to make its way into a 2.6 release?
msg97320 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-01-06 20:16
I've backported this to 2.6 in r77334 and to 3.1 in r77335.
History
Date User Action Args
2010-01-06 20:16:21r.david.murraysetpriority: normal

nosy: + r.david.murray
messages: + msg97320

stage: resolved
2009-10-28 14:38:33skelkersetnosy: + skelker
messages: + msg94631
2009-07-29 06:32:56amaury.forgeotdarcsetmessages: + msg91029
2009-07-28 22:36:15sridsetmessages: + msg91021
2009-07-28 22:20:44amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg91019

resolution: fixed
2009-07-18 03:06:39sridsetmessages: + msg90655
2009-07-18 03:05:49sridsetmessages: + msg90654
versions: + Python 3.1
2009-07-18 03:05:24sridcreate