bpo-34341: Fix appending to ZIP archives with the ZIP64 extension. (GH-8683)

This commit is contained in:
Serhiy Storchaka 2018-09-17 15:36:40 +03:00 committed by GitHub
parent da8d72c953
commit 9bdb7be482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View file

@ -770,6 +770,20 @@ class StoredTestZip64InSmallFiles(AbstractTestZip64InSmallFiles,
with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:
self.assertEqual(zipfp.namelist(), ["absolute"])
def test_append(self):
# Test that appending to the Zip64 archive doesn't change
# extra fields of existing entries.
with zipfile.ZipFile(TESTFN2, "w", allowZip64=True) as zipfp:
zipfp.writestr("strfile", self.data)
with zipfile.ZipFile(TESTFN2, "r", allowZip64=True) as zipfp:
zinfo = zipfp.getinfo("strfile")
extra = zinfo.extra
with zipfile.ZipFile(TESTFN2, "a", allowZip64=True) as zipfp:
zipfp.writestr("strfile2", self.data)
with zipfile.ZipFile(TESTFN2, "r", allowZip64=True) as zipfp:
zinfo = zipfp.getinfo("strfile")
self.assertEqual(zinfo.extra, extra)
@requires_zlib
class DeflateTestZip64InSmallFiles(AbstractTestZip64InSmallFiles,
unittest.TestCase):