Message 79408 - Python tracker (original) (raw)
I believe I have hit this bug. With Python 2.6.1 in a Gentoo Linux 64 bits.
This code:
from zipfile import ZipFile inzip = ZipFile('Document.odt') outzip = ZipFile('out.zip', 'w') for f in inzip.infolist(): if f.filename != 'content.xml': print f.filename, '(CRC: %s)' % f.CRC outzip.writestr(f, inzip.read(f.filename)) outzip.close()
Produces this output:
... styles.xml (CRC: 3930581528) test_odt.py:10: DeprecationWarning: 'l' format requires -2147483648 <= number <= 2147483647 outzip.writestr(f, inzip.read(f.filename)) ...
The CRC is not a 32bits signed, and then the module struct complains, here:
zipfile.py:1098 self.fp.write(struct.pack("<lLL", zinfo.CRC, zinfo.compress_size,
Apparently 'struct.pack' expects 'zinfo.CRC' to be a 32 signed it, which is not.
I can attach the 'Document.odt' file if you want.