Skip to content

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

Merged
merged 8 commits into from
Feb 19, 2018
Merged

bpo-32682: test_zlib improve version parsing #5347

merged 8 commits into from
Feb 19, 2018

Conversation

pmp-p
Copy link
Contributor

@pmp-p pmp-p commented Jan 26, 2018

fix odd version number parsing of zlib found at least on some android versions.

https://bugs.python.org/issue32682

https://bugs.python.org/issue32682

@the-knights-who-say-ni
Copy link

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!

@pmp-p pmp-p changed the title issue 32682: test_zlib improve version parsing # 32682: test_zlib improve version parsing Jan 26, 2018
@@ -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:
Copy link
Member

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

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)
Copy link
Member

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)

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@pmp-p pmp-p changed the title # 32682: test_zlib improve version parsing bpo-32682: test_zlib improve version parsing Jan 26, 2018
Copy link
Contributor Author

@pmp-p pmp-p left a comment

Choose a reason for hiding this comment

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

maybe this way

@pmp-p
Copy link
Contributor Author

pmp-p commented Jan 26, 2018

or this way ? ( sorry learning interface :p )

Copy link
Contributor Author

@pmp-p pmp-p left a 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

@pmp-p
Copy link
Contributor Author

pmp-p commented Jan 26, 2018

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@vstinner: please review the changes made to this pull request.

Copy link
Member

@zware zware left a 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.

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 )
Copy link
Member

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)?

elif not v[-1].isnumeric():
v[-1] = '0'

v = tuple( map( int, v ) )
Copy link
Member

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.)

and ( v[1] > 2 ) or ( v[1] == 2 ) \
and ( v[2] > 3 ) or ( v[2] == 3 ) \
and ( v[3] >= 5 )
del v
Copy link
Member

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.

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@zware zware added the skip news label Feb 4, 2018
@pmp-p
Copy link
Contributor Author

pmp-p commented Feb 5, 2018

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@vstinner, @zware: please review the changes made to this pull request.

Copy link
Member

@zware zware left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.6 tests Tests in the Lib/test dir labels Feb 18, 2018
@zware zware merged commit 4c7108a into python:master Feb 19, 2018
@miss-islington
Copy link
Contributor

Thanks @pmp-p for the PR, and @zware for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 19, 2018
@bedevere-bot
Copy link

GH-5751 is a backport of this pull request to the 3.7 branch.

@miss-islington
Copy link
Contributor

Sorry, @pmp-p and @zware, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 4c7108a77144493d0aa6fc0105b67d3797e143f5 2.7

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 19, 2018
@bedevere-bot
Copy link

GH-5752 is a backport of this pull request to the 3.6 branch.

@zware
Copy link
Member

zware commented Feb 19, 2018

@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 :)

@pmp-p pmp-p deleted the patch-3 branch February 19, 2018 03:56
miss-islington added a commit that referenced this pull request Feb 19, 2018
miss-islington added a commit that referenced this pull request Feb 19, 2018
@pmp-p pmp-p mannequin mentioned this pull request Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants