Message234589
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. |
|
Date |
User |
Action |
Args |
2015-01-24 00:52:11 | Danny.Yoo | set | recipients:
+ Danny.Yoo, gregory.p.smith |
2015-01-24 00:52:11 | Danny.Yoo | set | messageid: <1422060731.68.0.759457078819.issue23306@psf.upfronthosting.co.za> |
2015-01-24 00:52:11 | Danny.Yoo | link | issue23306 messages |
2015-01-24 00:52:11 | Danny.Yoo | create | |
|