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: replace unsafe six.PY3 with PY2 #1959

Merged
merged 2 commits into from
Jan 12, 2020

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Jan 8, 2020

Summary of changes

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 and work begins on Python 3.9+1.

There's some code which uses six.PY3:

if six.PY3:
    print("Python 3+ code")
else:
    print "Python 2 code"

Where:

PY3 = sys.version_info[0] == 3

When run on Python 4, this will run the Python 2 code! Instead, use six.PY2.

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

Pull Request Checklist

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details

@jaraco
Copy link
Member

jaraco commented Jan 12, 2020

Perhaps this issue should be fixed in six rather than in every package on PyPI. I'm pretty sure PY3 was never meant to mean PY<4.

@jaraco jaraco merged commit 70b3ec0 into pypa:master Jan 12, 2020
@hugovk hugovk deleted the fix-flake8-2020 branch January 12, 2020 06:42
@hugovk
Copy link
Contributor Author

hugovk commented Jan 12, 2020

It's a WONTFIX in six.

benjaminp/six#297

@Harmon758
Copy link

Harmon758 commented Jan 12, 2020

Note, it's almost certainly going to be 3.10. That's the consensus from the Python-Dev mailing list and that's what's being used to reference the future release in PEPs and CPython. There's even references to 3.11 and 3.12 already.

@hugovk
Copy link
Contributor Author

hugovk commented Jan 12, 2020

Thanks for the link!

@webknjaz
Copy link
Member

Found using asottile/flake8-2020

Maybe this should also be added to tests/requirements.txt

@hugovk
Copy link
Contributor Author

hugovk commented Jan 14, 2020

Good idea, please see PR #1968.

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.

None yet

4 participants