Issue 6511: zipfile: Invalid argument when opening zero-sized files (original) (raw)
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 "", line 1, in 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 >