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.

Author DragonSA
Recipients DragonSA
Date 2020-05-05.11:31:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588678317.42.0.364207173861.issue40510@roundup.psfhosted.org>
In-reply-to
Content
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:
```python[name=zip-round-trip.py]
#!/usr/bin/env python3
import io
import sys
import zipfile

compression = zipfile.ZIP_STORED

source = sys.stdin
dest = sys.stdout

with io.BytesIO(source.buffer.read()) 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 = source_zip.read(info)
            dest_zip.writestr(info, content, compression)

    buffer.seek(0)
    dest.buffer.write(buffer.read())
```

```shell
> python3.5 zip-round-trip.py < Book1.zip > Python.zip
> diff Book1.zip Python.zip
> python3.6 zip-round-trip.py < Book1.zip > Python.zip
> diff Book1.zip Python.zip
Binary files Book1.zip and Python.zip differ
```

[1] https://github.com/python/cpython/commit/18ee29d0b870caddc0806916ca2c823254f1a1f9
[2] https://github.com/python/cpython/blob/f01d1be97d740ea0369379ca305646a26694236e/Lib/zipfile.py#L1579
[3] https://github.com/python/cpython/blob/f01d1be97d740ea0369379ca305646a26694236e/Lib/zipfile.py#L1586
History
Date User Action Args
2020-05-05 11:31:57DragonSAsetrecipients: + DragonSA
2020-05-05 11:31:57DragonSAsetmessageid: <1588678317.42.0.364207173861.issue40510@roundup.psfhosted.org>
2020-05-05 11:31:57DragonSAlinkissue40510 messages
2020-05-05 11:31:57DragonSAcreate