[Python-checkins] r68662 - in python/branches/py3k: Lib/zipfile.py
Brett Cannon
brett at python.org
Sun Jan 18 01:16:18 CET 2009
test_zipfile has been failing forpy3k. Is this the cause or one of the
other zipfile patches?
On Sat, Jan 17, 2009 at 08:42, amaury. forgeotdarc
<python-checkins at python.org> wrote:
> Author: amaury.forgeotdarc
> Date: Sat Jan 17 17:42:26 2009
> New Revision: 68662
>
> Log:
> Merged revisions 68661 via svnmerge from
> svn+ssh://pythondev@svn.python.org/python/trunk
>
> ........
> r68661 | amaury.forgeotdarc | 2009-01-17 17:40:17 +0100 (Sat, 17 Jan 2009) | 5 lines
>
> #3997: zipfiles generated with more than 65536 files could not be opened
> with other applications.
>
> Reviewed by Martin, will backport to 2.6 and 3.0
> ........
>
>
> Modified:
> python/branches/py3k/ (props changed)
> python/branches/py3k/Lib/zipfile.py
>
> Modified: python/branches/py3k/Lib/zipfile.py
> ==============================================================================
> --- python/branches/py3k/Lib/zipfile.py (original)
> +++ python/branches/py3k/Lib/zipfile.py Sat Jan 17 17:42:26 2009
> @@ -28,7 +28,7 @@
>
> error = BadZipfile # The exception raised by this module
>
> -ZIP64_LIMIT= (1 << 31) - 1
> +ZIP64_LIMIT = (1 << 31) - 1
> ZIP_FILECOUNT_LIMIT = 1 << 16
> ZIP_MAX_COMMENT = (1 << 16) - 1
>
> @@ -1198,19 +1198,26 @@
>
> pos2 = self.fp.tell()
> # Write end-of-zip-archive record
> + centDirCount = count
> + centDirSize = pos2 - pos1
> centDirOffset = pos1
> - if pos1 > ZIP64_LIMIT:
> + if (centDirCount >= ZIP_FILECOUNT_LIMIT or
> + centDirOffset > ZIP64_LIMIT or
> + centDirSize > ZIP64_LIMIT):
> # Need to write the ZIP64 end-of-archive records
> zip64endrec = struct.pack(
> structEndArchive64, stringEndArchive64,
> - 44, 45, 45, 0, 0, count, count, pos2 - pos1, pos1)
> + 44, 45, 45, 0, 0, centDirCount, centDirCount,
> + centDirSize, centDirOffset)
> self.fp.write(zip64endrec)
>
> zip64locrec = struct.pack(
> structEndArchive64Locator,
> stringEndArchive64Locator, 0, pos2, 1)
> self.fp.write(zip64locrec)
> - centDirOffset = 0xFFFFFFFF
> + centDirCount = min(centDirCount, 0xFFFF)
> + centDirSize = min(centDirSize, 0xFFFFFFFF)
> + centDirOffset = min(centDirOffset, 0xFFFFFFFF)
>
> # check for valid comment length
> if len(self.comment) >= ZIP_MAX_COMMENT:
> @@ -1220,9 +1227,8 @@
> self.comment = self.comment[:ZIP_MAX_COMMENT]
>
> endrec = struct.pack(structEndArchive, stringEndArchive,
> - 0, 0, count % ZIP_FILECOUNT_LIMIT,
> - count % ZIP_FILECOUNT_LIMIT, pos2 - pos1,
> - centDirOffset, len(self.comment))
> + 0, 0, centDirCount, centDirCount,
> + centDirSize, centDirOffset, len(self.comment))
> self.fp.write(endrec)
> self.fp.write(self.comment)
> self.fp.flush()
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
More information about the Python-checkins
mailing list