Danny Yoo added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23306>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to