This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: [regression] ZipFile fails to round trip on some files
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: DragonSA
Priority: normal Keywords:

Created on 2020-05-05 11:31 by DragonSA, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit DragonSA, 2020-05-05 11:31
Messages (1)
msg368130 - (view) Author: David Naylor (DragonSA) * Date: 2020-05-05 11:31
With commit 18ee29d0b8 [1] a change was introduced that prevents a round-trip of some zip files (i.e. files generated by Microsoft Excel) due to the clobbering of `ZipInfo.flag_bits`[2] and `external_attr`[3].  

For example:
#!/usr/bin/env python3
import io
import sys
import zipfile

compression = zipfile.ZIP_STORED

source = sys.stdin
dest = sys.stdout

with io.BytesIO( as source, io.BytesIO() as buffer:
    with zipfile.ZipFile(source, "r") as source_zip, zipfile.ZipFile(buffer, "w") as dest_zip:
        dest_zip.comment = source_zip.comment
        for info in source_zip.infolist():
            content =
            dest_zip.writestr(info, content, compression)

> python3.5 < >
> diff
> python3.6 < >
> diff
Binary files and differ

Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84690
2020-05-05 11:31:57DragonSAcreate