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 Danny.Yoo
Recipients Danny.Yoo, gregory.p.smith
Date 2015-01-24.00:52:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1422060731.68.0.759457078819.issue23306@psf.upfronthosting.co.za>
In-reply-to
Content
Unfortunately, fixing just zlib.crc32 isn't quite enough for our purposes.  We still will see OverflowErrow in zipfile if compression is selected.


Demonstration code:

############################################
import zipfile

## Possible workaround: monkey-patch crc32 from binascii?!
import binascii
zipfile.crc32 = binascii.crc32

content = 'a'*(1<<31)
filename = '/tmp/zip_test.zip'

zf = zipfile.ZipFile(filename, "w",
                     compression=zipfile.ZIP_DEFLATED,
                     allowZip64=True)
zf.writestr('big', content)
zf.close()

zf = zipfile.ZipFile(filename, "r", allowZip64=True)
print zf.open('big').read() == content
#############################################


This will raise the following error under Python 2.7.6:

#############################################
$ python zip_test.py
Traceback (most recent call last):
  File "zip_test.py", line 13, in <module>
    zf.writestr('big', content)
  File "/usr/lib/python2.7/zipfile.py", line 1228, in writestr
    bytes = co.compress(bytes) + co.flush()
OverflowError: size does not fit in an int
#############################################



If we use compression=zipfile.ZIP_STORED, we don't see this error, but it kind of misses a major point of using zipfile.
History
Date User Action Args
2015-01-24 00:52:11Danny.Yoosetrecipients: + Danny.Yoo, gregory.p.smith
2015-01-24 00:52:11Danny.Yoosetmessageid: <1422060731.68.0.759457078819.issue23306@psf.upfronthosting.co.za>
2015-01-24 00:52:11Danny.Yoolinkissue23306 messages
2015-01-24 00:52:11Danny.Yoocreate