zipfile problems

James C. Ahlstrom jim at interet.com
Wed Apr 17 11:01:40 EDT 2002


Austin Luminais wrote:

> I have an archive of several hundred zip files, and I'm trying to
> automate unzipping them with the zipfile module (Python 2.2,
> Activestate).  Most of them work, but 58 of them don't.  Most that
> don't work get this error:
> 
> BadZipfile: File is not a zip file, or ends with a comment


I looked at 2force.zip, and it has an ending comment of 287 bytes
which seems to print "DC-1" in ascii art.  The zipfile module
will not handle zip files with ending comments because it
requires a search of the file.

 
> And a few get:
> 
> BadZipfile: Unsupported compression method 6 for file (filename)


The zipfile module supports compression methods 0 (no compression)
and 8 only, because the others are obsolete.

 
> WinZip and Powerdesk have no problem extracting these files.
> Would this be considered a bug in zipfile or zlib, or would they
> instead be considered corrupt files that WinZip happens to handle?


No, they just have unsupported compression methods and comments.

 
> A few of the files are available here:
> http://www.chromosome57.com/python/badfiles/


Thanks, that was very useful to see what was happening.

 

I can supply a patch so the files with comments can be read
if that would help you.  I don't have time to write a whole
decompression #6 method so at least some file would remain unreadable.

If you uncompress and recompress the problem files with WinZip
(or similar), then zipfile will have no trouble with them.

Jim Ahlstrom




More information about the Python-list mailing list