Zip problems

James C. Ahlstrom jim at interet.com
Thu Jun 28 12:29:37 EDT 2001


Ford Prefect wrote:

> I have problems using zipfile. Script below makes a zip file but when
> I try to extract files from the zip with WinAce or Windows Commander I
> get CRC error. At first I thought the problem was in Windows Commander
> and contacted the author (I also sent him the zip file). This is (part
> of) his reply:
>
> "This ZIP file is indeed faulty. In the header it has a bit set that
> the CRC
> is stored after the packed data, with header PK#7#8. But this header
> is
> missing and there is no CRC following the data. The CRC field of the
> local header is also empty."
>
> WinAce also reports CRC error.
>

I have looked at this, and I believe zipfile.py creates correct zip files.
The
claim that the header PK#7#8 should preceed the CRC is not correct.  The
CRC field has no header, and PK#7#8 is a special signature for spanned
archives.  Please see http://www.pkware.com/appnote.html for the definition
of the zip format.

Neither WinZip nor InfoZip reports any CRC errors on zipfile.py files.

A workaround would be to use zipfile.py to create zip files in which the CRC

does not follow the data, but is included in the file header.  The
zipfile.write()
method does not do this, but you can use zipfile.writestr() instead.  Use
zero
for the flag_bits, as the normal 0x08 means the CRC follows the file data.

If this isn't clear, send me e-mail.

Jim Ahlstrom





More information about the Python-list mailing list