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 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
hugovk added 2 commits Jan 8, 2020
@jaraco

This comment has been minimized.

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
6 checks passed
6 checks passed
Summary 1 potential rule
Details
codecov/patch 86.95% of diff hit (target 84.68%)
Details
codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +2.27% compared to 7e97def
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
@hugovk hugovk deleted the hugovk:fix-flake8-2020 branch Jan 12, 2020
@hugovk

This comment has been minimized.

Copy link
Contributor Author

hugovk commented Jan 12, 2020

It's a WONTFIX in six.

benjaminp/six#297

@Harmon758

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

hugovk commented Jan 12, 2020

Thanks for the link!

@webknjaz

This comment has been minimized.

Copy link
Member

webknjaz commented Jan 14, 2020

Found using asottile/flake8-2020

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

@hugovk hugovk mentioned this pull request Jan 14, 2020
2 of 2 tasks complete
@hugovk

This comment has been minimized.

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
Projects
None yet
4 participants
You can’t perform that action at this time.