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 version comparison for Python 3.10 and 4 #35776

Merged
merged 2 commits into from Jan 16, 2020

Conversation

@hugovk
Copy link
Contributor

hugovk commented Jan 11, 2020

Fix for Python 3.10: use sys.version_info instead of comparing sys.version to string

Don't assume the minor version is a single character: '3.10' >= '3.4' is False!


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

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.

@hugovk hugovk requested review from kkimdev, MarkDaoust and mdanatg as code owners Jan 11, 2020
@tensorflow-bot tensorflow-bot bot added the size:M label Jan 11, 2020
@googlebot googlebot added the cla: yes label Jan 11, 2020
@hugovk hugovk changed the title Fix for version comparison for Python 3.10 and 4 Fix version comparison for Python 3.10 and 4 Jan 11, 2020
@gbaned gbaned self-assigned this Jan 13, 2020
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Jan 13, 2020
tensorflow/tools/docs/generate_lib.py Outdated Show resolved Hide resolved
PR Queue automation moved this from Assigned Reviewer to Reviewer Requested Changes Jan 14, 2020
@tensorflow-bot tensorflow-bot bot removed the ready to pull label Jan 14, 2020
@hugovk hugovk force-pushed the hugovk:fix-flake8-2020 branch from cb70d02 to e6978fe Jan 15, 2020
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Jan 15, 2020
@hugovk hugovk force-pushed the hugovk:fix-flake8-2020 branch from e6978fe to 9db7340 Jan 15, 2020
PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes Jan 15, 2020
@tensorflow-bot tensorflow-bot bot removed the ready to pull label Jan 15, 2020
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Jan 15, 2020
tensorflow-copybara pushed a commit that referenced this pull request Jan 16, 2020
PiperOrigin-RevId: 290045329
Change-Id: Ie7497c986d4002bd09dc1e3d6c31b332f0e50185
@tensorflow-copybara tensorflow-copybara merged commit 9db7340 into tensorflow:master Jan 16, 2020
11 checks passed
11 checks passed
Android Demo App Internal CI build successful
Details
Linux GPU Internal CI build successful
Details
MacOS CPU Python3 Internal CI build successful
Details
MacOS Python2 and CC Internal CI build successful
Details
Ubuntu CPU Internal CI build successful
Details
Ubuntu Sanity Internal CI build successful
Details
Windows Bazel Internal CI build successful
Details
Windows Bazel GPU Internal CI build successful
Details
cla/google All necessary CLAs are signed
feedback/copybara Google internal checks PASS for runs with create time 2020-01-16T12:51:04.280916908Z,2020-01-16T05:35:48.222359703Z,2020-01-16T04:52:58.4...
Details
import/copybara Change imported to the internal review system
Details
PR Queue automation moved this from Approved by Reviewer to Merged Jan 16, 2020
@hugovk hugovk deleted the hugovk:fix-flake8-2020 branch Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PR Queue
  
Merged
6 participants
You can’t perform that action at this time.