-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-32682: test_zlib improve version parsing #5347
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
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Lib/test/test_zlib.py
Outdated
@@ -751,7 +751,12 @@ def test_large_unconsumed_tail(self, size): | |||
def test_wbits(self): | |||
# wbits=0 only supported since zlib v1.2.3.5 | |||
# Register "1.2.3" as "1.2.3.0" | |||
v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4) | |||
if zlib.ZLIB_RUNTIME_VERSION.find('-')>=0: |
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.
"-" in zlib.ZLIB_RUNTIME_VERSION would be simpler
Lib/test/test_zlib.py
Outdated
v = list(map( int , zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.')[:3] )) | ||
v.append(0) | ||
else: | ||
v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4) |
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.
You should factorize the code between the if/else block. Something like:
v = zlib.ZLIB_RUNTIME_VERSION
if "-" in v:
v = v.split('-',1)[0]
v = (v + ".0").split(".", 4)
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
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.
maybe this way
or this way ? ( sorry learning interface :p ) |
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.
maybe a line too long
I have made the requested changes; please review again |
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
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.
Just a couple of minor fixes needed.
Lib/test/test_zlib.py
Outdated
supports_wbits_0 = ( v[0] > 1 ) or ( v[0] == 1 ) \ | ||
and ( v[1] > 2 ) or ( v[1] == 2 ) \ | ||
and ( v[2] > 3 ) or ( v[2] == 3 ) \ | ||
and ( v[3] >= 5 ) |
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.
Why not supports_wbits_0 = v >= (1, 2, 3, 5)
?
Lib/test/test_zlib.py
Outdated
elif not v[-1].isnumeric(): | ||
v[-1] = '0' | ||
|
||
v = tuple( map( int, v ) ) |
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.
No need for the extra spaces around (
or )
; v = tuple(map(int, v))
. (See PEP 8.)
Lib/test/test_zlib.py
Outdated
and ( v[1] > 2 ) or ( v[1] == 2 ) \ | ||
and ( v[2] > 3 ) or ( v[2] == 3 ) \ | ||
and ( v[3] >= 5 ) | ||
del v |
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.
No need for del v
.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
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.
(cherry picked from commit 4c7108a) Co-authored-by: pmp-p <[email protected]>
GH-5751 is a backport of this pull request to the 3.7 branch. |
Sorry, @pmp-p and @zware, I could not cleanly backport this to |
(cherry picked from commit 4c7108a) Co-authored-by: pmp-p <[email protected]>
GH-5752 is a backport of this pull request to the 3.6 branch. |
@serhiy-storchaka This doesn't appear to need to go back to 2.7; would you mind taking care of that one way or the other? I would vote for the simple solution of just removing the label :) |
(cherry picked from commit 4c7108a) Co-authored-by: pmp-p <[email protected]>
(cherry picked from commit 4c7108a) Co-authored-by: pmp-p <[email protected]>
fix odd version number parsing of zlib found at least on some android versions.
https://bugs.python.org/issue32682
https://bugs.python.org/issue32682