Skip to content

gh-113924: Allow pre-compressed data to be written into a zip via zipfile. - #113925

Draft
gpshead wants to merge 3 commits into
python:mainfrom
gpshead:zipfile/write/pre-compressed
Draft

gpshead wants to merge 3 commits into
python:mainfrom
gpshead:zipfile/write/pre-compressed

Conversation

@gpshead

@gpshead gpshead commented Jan 10, 2024 •

Copy link
Copy Markdown
Member

Intended to be used when constructing zip files via a system that can parallelize and cache all actions including compressing individual input file contents so that you can distribute actions & avoid recomputation.

This also adds the missing ability to pass in pre-constructed ZipInfo to the write method as pre-compressed data needs its original file_size and uncompressed data CRC to also have been pre-computed.

Intended to be used when constructing zip files via a system that can
parallelize and cache all actions including compressing individual input
file contents so that you can distribute actions & avoid recomputation.
Comment thread Lib/zipfile/__init__.py
Comment on lines +1016 to +1017
f"Bad CRC-32 for file {self.name!r} expected "
f"{hex(self._expected_crc)} != {hex(self._running_crc)}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you keep the beginning of the error message identical to keep compatibility?
If not, then it could be easier to read if it was like bad crc32 {got value} for file {name}, expected {expected value}. For now it’s slightly unpleasant to read about bad value, expected, expected, bad.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants