[ python-Bugs-849218 ] ZipInfo shows incorrect file size for large files

SourceForge.net noreply at sourceforge.net
Tue Dec 23 14:14:14 EST 2003


Bugs item #849218, was opened at 2003-11-25 15:09
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=849218&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Waldemar Osuch (osuchw)
Assigned to: Nobody/Anonymous (nobody)
Summary: ZipInfo shows incorrect file size for large files

Initial Comment:
When dealing with large zipped files I've noticed that
ZipInfo instance was reporting incorrect file size.
I could reproduce the error by:

txtfile = file('bigone.txt','w')
for i in xrange(10**8):
    txtfile.write('%-9s Hello World\n'%i) 
txtfile.close()
os.stat('bigone.txt').st_size
2300000000L

Now I zip the bugger and:
z = zipfile.ZipFile(file('bigone.zip','r'))
fi = z.infolist()[0]
fi.file_size
-1994967296

After changing zipfile.py on line 26 from:
structCentralDir = "<4s4B4H3l5HLl"
to:
structCentralDir = "<4s4B4H3L5HLl"

I get:
z = zipfile.ZipFile(file('bigone.zip','r'))
fi = z.infolist()[0]
fi.file_size
2300000000L

Sorry for a digression but it would be nice to have
something similar to a module from Twisted distribution
(twisted.python.zipstream) in standard library.
The above module allows to read a zipped file in chunks
using iterator.  It would help tremendously when
dealing with large files.

----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2003-12-23 14:14

Message:
Logged In: YES 
user_id=11375

This isn't a sufficient fix; zipfile.py doesn't seem to handle files 
whose sizes don't fit into 32 bits.  The ZIP specification
at http://www.pkware.
com/products/enterprise/white_papers/appnote.html#2 describes a 
zip64 format which can handle files larger than this limit; supporting 
it would require more extensive changes to zipfile.py.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=849218&group_id=5470



More information about the Python-bugs-list mailing list