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

Fix for Python 4 #1574

Closed
wants to merge 1 commit into from
Closed

Fix for Python 4 #1574

wants to merge 1 commit into from

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Aug 26, 2019

We don't yet know if 3.10 or 4.0 will follow Python 3.9, but whichever it is, it will probably happen in 2020 when Python 3.9 reaches beta.

There's some code which checks the Python major version is exactly 3, similar to this:

if sys.version_info[0] == 3:
    # Python 3+ code
else:
    # Python 2 code

When run on Python 4, it will run the Python 2 code! Instead:

if sys.version_info[0] >= 3:
    # Python 3+ code
else:
    # Python 2 code

Found using https://github.com/asottile/flake8-2020:

$ pip install -U flake8-2020
...
$ flake8 --select YTT
./scripts/internal/winmake.py:34:7: YTT201: `sys.version_info[0] == 3` referenced (python4), use `>=`
./psutil/_common.py:41:7: YTT201: `sys.version_info[0] == 3` referenced (python4), use `>=`
./psutil/_compat.py:18:7: YTT201: `sys.version_info[0] == 3` referenced (python4), use `>=`

@giampaolo
Copy link
Owner

giampaolo commented Aug 27, 2019

We still don't know what Python is gonna be called by then, which (if I'm not mistaken) should be 3+ years from now, so let's cross that bridge when we come to it. ;)

PS: my hunch is it's gonna be called 3.10, precisely to avoid these kinds of breakage.

@giampaolo giampaolo closed this Aug 27, 2019
@hugovk
Copy link
Contributor Author

hugovk commented Aug 27, 2019

Yeah, we don't know which it will be and 3.10 will also have problems (eg. sys.version[:3] returns 3.1, not 3.10!) but probably less severe than 4.0.

And it'll be sooner than you think.

Python 3.9 reaches beta in February 2020, and that is when the Python 3.9+1 branch will be made and testing will begin. That's only 6 months from now.

There's a proposal in the 3.9 PEP to move to a 9 month release cadence, which could mean 3.9+1 final is out around November 2020, 1 year and 3 months from now.

If they stick with an 18-month cadence, the final will be out around August 2021, two years from now.

Do you know if psutil is vendored in any other packages?

@giampaolo
Copy link
Owner

giampaolo commented Aug 27, 2019

Yeah, we don't know which it will be and 3.10 will also have problems (eg. sys.version[:3] returns 3.1, not 3.10!)

We use sys.version_info[0] (== 3) though so 3.10 won't be a problem.

Do you know if psutil is vendored in any other packages?

Not that I'm aware of, no.

@giampaolo giampaolo added the bug label Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants