zipfile 2GB problems?

John Machin sjmachin at lexicon.net
Tue Jul 17 00:18:01 CEST 2007


On Jul 17, 4:59 am, xamdam <maxkhe... at gmail.com> wrote:
> On Jul 15, 5:39 pm, Steve Holden <st... at holdenweb.com> wrote:
>
>
>
> > xamdam wrote:
> > >>> Additional info: my file is from a data provider, do not know what
> > >>> they used to compress it. Previous files worked ok, this one is the
> > >>> 1st over 2GB. Winzip has no problem with it.
> > >> It could be you are using a Python with an in-built limit of 2GB on file
> > >> size. What happens if you open the file, seek past the 2GB point and
> > >> then try and read data?
>
> > > Steve,
> > > I used is_zipfile function, which from does exactly that from a quick
> > > read - goes to the end, reads expected string. It worked fine. Tried
> > > regular Windows 2.4.4 and 2.5.1, same result.
>
> > Fine, if it isn't file size limitations I suspect you need to post some
> > code and a traceback so we can get better insight into exactly what the
> > problem is.
>
> It's failing in the ZipFile constructor, which ends up throwing
>
> zipfile(2.4.3).py:291> raise BadZipfile, "Bad magic number for file
> header"

Suggestion 1: RTEDManual

Manual says:
"""
12.4.1 ZipFile Objects

class ZipFile( file[, mode[, compression[, allowZip64]]])
[snip]
If allowZip64 is True zipfile will create ZIP files that use the ZIP64
extensions when the zipfile is larger than 2 GB. If it is false (the
default) zipfile will raise an exception when the ZIP file would
require ZIP64 extensions. ZIP64 extensions are disabled by default
because the default zip and unzip commands on Unix (the InfoZIP
utilities) don't support these extensions.
"""

It's vague about whether allowZip64=True is needed for reading -- have
you tried it?

Suggestion 2: RTEDCode. At the line you quoted, it is checking the
first 4 bytes of the file for a signature: 'PK\x03\x04'
Do this:
    print repr(open('yourfile.zip', 'rb').read(4))
Tell us what you find.

Suggestion 3: RTEDWordsOfWisdomOfSteveHolden. IOW supply the *WHOLE*
EDing traceback.

HTH,
John




More information about the Python-list mailing list