[Python-Dev] zipfile.py and InfoZIP files
James C. Ahlstrom
Mon, 06 Nov 2000 08:11:25 -0500
"M.-A. Lemburg" wrote:
I am happy to modify zipfile.py as desired by this group.
> I'm having trouble opening ZIP files created using InfoZIP's
> zip utility (which uses zlib) with zipfile.py:
> >>> x = z.read('README')
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "/home/lemburg/lib/zipfile.py", line 242, in read
> bytes = dc.decompress(bytes)
> zlib.error: Error -3 while decompressing: incomplete dynamic bit lengths tree
> Is this due to the installed zlib on my system being incompatible,
> or is this a bug in zipfile.py ? I have libz version 1.1.3 and
> zip version 2.2.
I "borrowed" the zlib code from someone else, and it uses
undocumented features. Since WinZip seems happy with the compression
I left it alone. I wouldn't be surprised if other utilities have
problems, especially if they use zlib. I am not sure what to
do about this. My starting view is that there is only one
compression method, and if WinZip accepts it, then InfoZip
is wrong. Is there perhaps a version difference in zlib
in Python vs InfoZip?
Could you send me an InfoZip zip file?
> Also, I wonder why zipfile forces the mode flag to be 'r',
> 'w' and 'a' -- wouldn't it make more sense to only add 'b', etc.
> to the mode flag instead ?!
The 'b' is not necessary, as it is always added by zipfile.py
when the file is opened. The [rwa] each do something
different, and aren't really the same as a file open. I
am not sure what you mean here.
> The ZipFile is also missing some kind of method which
> extracts files in the ZIP archive to a file-like object. This
> would be very useful for extracting large files from a ZIP
> archive without having to first read in the whole file into
The "read(self, name)" method returns the bytes, which you can
write to a file if you want. What new method would you like?