BadZipfile "file is not a zip file"

Chris Mellon arkanes at gmail.com
Fri Jan 9 16:14:35 CET 2009


On Fri, Jan 9, 2009 at 9:05 AM, webcomm <ryandw at gmail.com> wrote:
> On Jan 9, 3:46 am, Carl Banks <pavlovevide... at gmail.com> wrote:
>> The zipfile format is kind of brain dead, you can't tell where the end
>> of the file is supposed to be by looking at the header.  If the end of
>> file hasn't yet been reached there could be more data.  To make
>> matters worse, somehow zip files came to have text comments simply
>> appended to the end of them.  (Probably this was for the benefit of
>> people who would cat them to the terminal.)
>>
>> Anyway, if you see something that doesn't adhere to the zipfile
>> format, you don't have any foolproof way to know if it's because the
>> file is corrupted or if it's just an appended comment.
>>
>> Most zipfile readers use a heuristic to distinguish.  Python's zipfile
>> module just assumes it's corrupted.
>>
>> The following post from a while back gives a solution that tries to
>> snip the comment off so that zipfile module can handle it.  It might
>> help you out.
>>
>> http://groups.google.com/group/comp.lang.python/msg/c2008e48368c6543
>>
>> Carl Banks
>
> Thanks Carl.  I tried Scott's getzip() function yesterday... I
> stumbled upon it in my searches.  It didn't seem to help in my case,
> though it did produce a different error:  ValueError, substring not
> found.  Not sure what that means.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

This is a ticket about another issue or 2 with invalid zipfiles that
the zipfile module won't load, but that other tools will compensate
for:

http://bugs.python.org/issue1757072



More information about the Python-list mailing list