Skip to content

Consider reversed operands order when comparing version info #10288

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 4 commits into from
Apr 8, 2021
Merged

Consider reversed operands order when comparing version info #10288

merged 4 commits into from
Apr 8, 2021

Conversation

kamilturek
Copy link
Contributor

Description

Closes #10264.

Consider reversed order of operands when trying to compare version info. When reversed order is used, operator is reversed as well for correct comparison.

index = contains_sys_version_info(expr.operands[1])
thing = contains_int_or_tuple_of_ints(expr.operands[0])
op = reverse_op[op]
if index is None or thing is None:
Copy link
Member

Choose a reason for hiding this comment

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

This check is redundant, since the conditions below won't trigger if either value is None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. Good point 👍

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Please remove the redundant check.

@kamilturek
Copy link
Contributor Author

@JelleZijlstra One job on Travis CI has failed for some weird reason, doesn't look like thing related to this PR.

@JelleZijlstra
Copy link
Member

Yeah that looks harmless. I'll merge this PR, thanks for your contributions!

@JelleZijlstra JelleZijlstra merged commit 1567e36 into python:master Apr 8, 2021
@kamilturek kamilturek deleted the sys-version-comparison-order branch April 8, 2021 19:27
sthagen added a commit to sthagen/python-mypy that referenced this pull request Apr 10, 2021
Consider reversed operands order when comparing version info (python#10288)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python version check is sensitive to comparison order
2 participants