-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-112346: Bugfix: Remove faster codepath from gzip.compress as it introduces behavioral inconsistencies #114116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So is there any procedure for News entries for bugfixes that need to be backported to older versions of CPython? |
I would suggest the following fixup to make this work on BE (mtime is always LE, regardless of the host endianness):
|
Thanks for the suggestion @iii-i . That was an oversight on my part. I am going to pin in the hope this fix gets noticed. |
ping |
Ping @gpshead . Could you shine your light on this? It's only a very small change and it has remained under the radar for almost half a year now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except using assert
in the test.
Lib/test/test_gzip.py
Outdated
for mtime in (0, 42): | ||
with self.subTest(mtime=mtime): | ||
compress = gzip.compress(data1, compresslevel=1, mtime=mtime) | ||
assert struct.unpack("<IxB", compress[4:10]) == (mtime, 255) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TestCase assertion methods instead of the assert statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Thanks for reviewing this so quickly @serhiy-storchaka . I added a news entry. |
I suggest not making this change given how long it has been the behavior of released Pythons. We cannot backport this to 3.11 as it is not a security issue. And anyone picking a change like this up in a patch release is just as likely to run into problems with the behavior change between differing Python versions. |
@gpshead That makes sense. Sorry, I went into panic mode when code changes I made gave someone some reproducibility troubles. |
As mentioned in the linked issue, delegating to
zlib.compress
causes behavorial changes in the OS byte. As a result this change caused reproducible build failures. The separate codepath caused issues before as well:#90425
Therefore the codepath should be removed. Speed ain't everything. The mention of zlib.compress in the documentation is maintained so users who not have specific requirements can use the speedier path.
This change needs to be backported to 3.11 and 3.12
📚 Documentation preview 📚: https://cpython-previews--114116.org.readthedocs.build/