GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: replace unsafe six.PY3 with PY2 for better future compatibility with Python 4 by hugovk · Pull Request #10081 · googleapis/google-cloud-python

Conversation

@hugovk

@hugovk hugovk commented Jan 9, 2020 •
edited by plamut
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #10158.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • [trivial] Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
    (edit by @plamut: opened the issue for better traceability)
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • [n/a] Appropriate docs were updated (if necessary)

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hugovk
hugovk requested review from anguillanneuf, busunkim96, crwilcox, frankyn, plamut, pradn and tseaver as code owners January 9, 2020 09:30
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 9, 2020
@hugovk
hugovk force-pushed the fix-flake8-2020 branch 2 times, most recently from 8f15925 to 4b7b089 Compare January 9, 2020 09:34
plamut
plamut previously approved these changes Jan 9, 2020
View reviewed changes

@plamut plamut left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Testing for "is (not) PY2" instead of "is (not) PY3" is indeed more robust, thanks for catching that!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
plamut dismissed their stale review January 9, 2020 09:52

The change is done to an auto-generated file

plamut
plamut suggested changes Jan 9, 2020
View reviewed changes

@plamut plamut left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

(speaking for the PubSub library)

The change is good, but needs to be made in the synth file that is used to generate the file changed here.

The changes to the files in other libraries are fine, as those files are not auto-generated (AFAIK).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
fix: fix for Python 4: replace unsafe six.PY3 with PY2
1401457
@plamut plamut changed the title Fix for Python 4: replace unsafe six.PY3 with PY2 fix: replace unsafe six.PY3 with PY2 for better future compatibility with Python 4 Jan 9, 2020
@hugovk
hugovk force-pushed the fix-flake8-2020 branch from 153d003 to 1401457 Compare January 9, 2020 17:36
plamut
plamut reviewed Jan 9, 2020
View reviewed changes

@plamut plamut left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM with one final remark.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread storage/tests/unit/test__signing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
Fix wording
09c70b6
plamut
plamut approved these changes Jan 9, 2020
View reviewed changes

@plamut plamut left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Thanks @hugovk!

Will delay merging for a day or so if anybody else wants to review it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@plamut plamut added api: logging Issues related to the Cloud Logging API. api: pubsub Issues related to the Pub/Sub API. api: storage Issues related to the Cloud Storage API. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jan 9, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 10, 2020
@plamut

plamut commented Jan 10, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The test failures are not related, also happen on master. Investigating.

Update: At least for logging, the test failure is caused by an out-of-date assertion - an optional timeout was added to core recently. Will be fixed in #10087.

Update 2: The Storage failures also seem to be a regression, will submit a fix for that, too (edit: submitted).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 15, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 15, 2020
@plamut
plamut merged commit 7a64502 into googleapis:master Jan 15, 2020
@hugovk
hugovk deleted the fix-flake8-2020 branch January 15, 2020 15:22
@yoshi-automation yoshi-automation mentioned this pull request Jan 29, 2020
chore(asset): bump copyright year to 2020, tweak docstring formatting (via synth) #10223
Merged
This was referenced Jan 29, 2020
chore(automl): bump copyright year to 2020, tweak docstring formatting (via synth) #10224
Merged
chore(bigquery): bump copyright year to 2020, tweak docstring formatting (via synth) #10225
Merged
chore(billingbudgets): bump copyright year to 2020, tweak docstring formatting (via synth) #10227
Merged
docs(datalabeling): update docstrings; bump copyright year to 2020 (via synth) #10229
Merged
feat(documentai): bump copyright year to 2020, tweak docstring formatting (via synth) #10230
Merged
fix(iam): bump copyright year to 2020 (via synth) #10231
Merged
chore(iot): bump copyright year to 2020 (via synth) #10232
Merged
fix(irm): change default retry and timeout config; bump copyright year to 2020 (via synth) #10233
Merged
docs(language): change docstring formatting; bump copyright year to 2020 (via synth) #10234
Merged
chore(phishingprotection): bump copyright year to 2020 (via synth) #10235
Merged
chore(redis): bump copyright year to 2020, tweak docstring formatting (via synth) #10237
Merged
chore(speech): bump copyright year to 2020, tweak docstring formatting (via synth) #10238
Merged
fix(talent): change default timeout values; edit docstrings; bump copyright year to 2020 (via synth) #10239
Merged
chore(texttospeech): bump copyright year to 2020, tweak docstring formatting (via synth) #10240
Merged
chore(trace): bump copyright year to 2020, tweak docstring formatting (via synth) #10241
Merged
chore(vision): bump copyright year to 2020, tweak docstring formatting (via synth) #10242
Merged
chore(websecurityscanner): bump copyright year to 2020, tweak docstring formatting (via synth) #10243
Merged
[CHANGE ME] Re-generated container to pick up changes in the API or client library generator. #10256
Closed
[CHANGE ME] Re-generated datastore to pick up changes in the API or client library generator. #10261
Closed
parthea pushed a commit that referenced this pull request Nov 24, 2025
@hugovk @plamut
fix: replace unsafe six.PY3 with PY2 for better future compatibility …
5fdb0a0
…with Python 4 (#10081)

* fix: fix for Python 4: replace unsafe six.PY3 with PY2

* Fix wording
parthea pushed a commit that referenced this pull request Mar 2, 2026
@hugovk @plamut
fix: replace unsafe six.PY3 with PY2 for better future compatibility …
5d3289c
…with Python 4 (#10081)

* fix: fix for Python 4: replace unsafe six.PY3 with PY2

* Fix wording
parthea pushed a commit that referenced this pull request Mar 9, 2026
@hugovk @plamut
fix: replace unsafe six.PY3 with PY2 for better future compatibility …
0a5e050
…with Python 4 (#10081)

* fix: fix for Python 4: replace unsafe six.PY3 with PY2

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

Reviewers

@anguillanneuf anguillanneuf Awaiting requested review from anguillanneuf
@busunkim96 busunkim96 Awaiting requested review from busunkim96
@crwilcox crwilcox Awaiting requested review from crwilcox
@frankyn frankyn Awaiting requested review from frankyn
@pradn pradn Awaiting requested review from pradn
@tseaver tseaver Awaiting requested review from tseaver
1 more reviewer
@plamut plamut plamut approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: logging Issues related to the Cloud Logging API. api: pubsub Issues related to the Pub/Sub API. api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Test for "if not PY2" in compatibility code, rather than "if PY3"

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@hugovk @plamut @busunkim96 @googlebot @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.