cpython: 64a19fe3a16a (original) (raw)

Mercurial > cpython

changeset 104352:64a19fe3a16a

Issue #26293: Fixed writing ZIP files that starts not from the start of the file. Offsets in ZIP file now are relative to the start of the archive in conforming to the specification. [#26293]

Serhiy Storchaka storchaka@gmail.com
date Fri, 07 Oct 2016 22:25:05 +0300
parents def217aaad2f(current diff)b06e75ae1981(diff)
children a60d0e80cc1d
files Lib/zipfile.py Misc/NEWS
diffstat 3 files changed, 62 insertions(+), 15 deletions(-)[+] [-] Lib/test/test_zipfile.py 43 Lib/zipfile.py 30 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -420,6 +420,49 @@ class StoredTestsWithSourceFile(Abstract f.seek(len(data)) with zipfile.ZipFile(f, "r") as zipfp: self.assertEqual(zipfp.namelist(), [TESTFN])

+

+

+

+

+

def test_ignores_newline_at_end(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:

--- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1103,10 +1103,10 @@ class ZipFile: # even if no files are added to the archive self._didModify = True try:

@@ -1127,7 +1127,7 @@ class ZipFile: # set the modified flag so central directory gets written # even if no files are added to the archive self._didModify = True

@@ -1171,17 +1171,18 @@ class ZipFile: offset_cd = endrec[_ECD_OFFSET] # offset of central directory self._comment = endrec[_ECD_COMMENT] # archive comment

if self.debug > 2:

@@ -1221,7 +1222,7 @@ class ZipFile: t>>11, (t>>5)&0x3F, (t&0x1F) * 2 ) x._decodeExtra()

@@ -1685,11 +1686,10 @@ class ZipFile: file_size = zinfo.file_size compress_size = zinfo.compress_size

extra_data = zinfo.extra min_version = 0 @@ -1736,7 +1736,7 @@ class ZipFile: # Write end-of-zip-archive record centDirCount = len(self.filelist) centDirSize = pos2 - self.start_dir

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -64,6 +64,10 @@ Core and Builtins Library ------- +- Issue #26293: Fixed writing ZIP files that starts not from the start of the