Skip to content
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

Inappropreate version comparison #8

Open
te-koyanagi opened this issue Apr 21, 2023 · 1 comment
Open

Inappropreate version comparison #8

te-koyanagi opened this issue Apr 21, 2023 · 1 comment

Comments

@te-koyanagi
Copy link

Found a following inappropriate version comparison in base_model.py:

IS_PYTHON2 = sys.version_info.major == 2 or sys.version < '3'
IS_PYTHON35_UP = sys.version >= '3.5'

The versions cannot be compared by using the string equal operator.
For example, in case of sys.version = '3.10.6', sys.version >= '3.5' becomes False.
Because '1' of the third character of sys.version is less than '5'. But guess it intended to be True in this case.

In addition, often sys.version includes additional information, for example '3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]'.

It should be replaced with a correction such as:

IS_PYTHON2 = sys.version_info.major < 3
IS_PYTHON35_UP = sys.version_info.major > 3 or (sys.version_info.major == 3 and sys.version_info.minor >= 5)

Thanks.

@te-koyanagi
Copy link
Author

Workaround: Set a version manually, for example:

import sys
sys.version = "3.5"

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

No branches or pull requests

1 participant