Skip to content

Fix for Python 4: replace unsafe six.PY3 with PY2#1959

Merged
jaraco merged 2 commits into
pypa:masterfrom
hugovk:fix-flake8-2020
Jan 12, 2020
Merged

Fix for Python 4: replace unsafe six.PY3 with PY2#1959
jaraco merged 2 commits into
pypa:masterfrom
hugovk:fix-flake8-2020

Conversation

@hugovk

@hugovk hugovk commented Jan 8, 2020

Copy link
Copy Markdown
Contributor

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

jaraco commented Jan 12, 2020

Copy link
Copy Markdown
Member

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

hugovk commented Jan 12, 2020

Copy link
Copy Markdown
Contributor Author

It's a WONTFIX in six.

benjaminp/six#297

@Harmon758

Harmon758 commented Jan 12, 2020

Copy link
Copy Markdown

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

hugovk commented Jan 12, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for the link!

@webknjaz

Copy link
Copy Markdown
Member

Found using asottile/flake8-2020

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

@hugovk

hugovk commented Jan 14, 2020

Copy link
Copy Markdown
Contributor Author

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.

4 participants