Skip to content

Conversation

@hugovk
Copy link
Contributor

@hugovk hugovk commented Aug 25, 2019

Summary of changes

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

six.py defines these:

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

There's several places in the codebase like:

if six.PY3:
    pass  # Python 3+ stuff

if not six.PY3:
    pass  # Python 2 stuff

But when run on Python 4, it will skip the Python 3+ stuff and run the Python 2 stuff!

This PR flips it around:

if not six.PY2:
    pass  # Python 3+ stuff

if six.PY2:
    pass  # Python 2 stuff

Found using:

$ pip install -U flake8-2020
...
$ flake8 --select YTT
./dateutil/test/test_parser.py:465:16: YTT202: `six.PY3` referenced (python4), use `not six.PY2`
./dateutil/test/test_rrule.py:2287:16: YTT202: `six.PY3` referenced (python4), use `not six.PY2`
./dateutil/test/test_rrule.py:4582:16: YTT202: `six.PY3` referenced (python4), use `not six.PY2`
./dateutil/test/test_isoparser.py:309:20: YTT202: `six.PY3` referenced (python4), use `not six.PY2`
./dateutil/test/test_isoparser.py:359:8: YTT202: `six.PY3` referenced (python4), use `not six.PY2`

Pull Request Checklist

  • Changes have tests
  • Authors have been added to AUTHORS.md
  • News fragment added in changelog.d. See CONTRIBUTING.md for details

Copy link
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a news fragment in changelog.d?

It should be named 950.bugfix.rst. The text can be something like:

Changed compatibility logic to support a potential Python 4.0 release. Patch by Hugo van Kemenade (gh pr #950)

@pganssle pganssle added this to the Bugfix release milestone Aug 27, 2019
hugovk and others added 2 commits August 27, 2019 17:59
Co-Authored-By: Paul Ganssle <p.ganssle@gmail.com>
@hugovk
Copy link
Contributor Author

hugovk commented Aug 27, 2019

Added!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants