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

Use print() function in both Python 2 and Python 3 #722

Merged
merged 3 commits into from
Jul 22, 2019

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 21, 2019

Legacy print statements are syntax errors in Python 3 but print() function works as expected in both Python 2 and Python 3. Also fixed some undefined names.

Four undefined names remain...

$ flake8 . --count --show-source --statistics --select=E9,F63,F7,F82

./samples/coordinate/coordinate.py:60:13: F821 undefined name 'build'
  service = build('coordinate', 'v1', http=http)
            ^
./samples/coordinate/coordinate.py:60:44: F821 undefined name 'http'
  service = build('coordinate', 'v1', http=http)
                                           ^
./samples/coordinate/coordinate.py:64:46: F821 undefined name 'FLAGS'
    jobs_result = service.jobs().list(teamId=FLAGS.teamId).execute(http=http)
                                             ^
./samples/coordinate/coordinate.py:64:73: F821 undefined name 'http'
    jobs_result = service.jobs().list(teamId=FLAGS.teamId).execute(http=http)
                                                                        ^
4     F821 undefined name 'build'
4

Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 21, 2019
Copy link
Contributor

@busunkim96 busunkim96 left a comment

Choose a reason for hiding this comment

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

Thank you @cclauss!

@busunkim96 busunkim96 merged commit 9fdc2b2 into googleapis:master Jul 22, 2019
@cclauss cclauss deleted the modernize-Python-2-codes branch July 22, 2019 17:54
@@ -156,7 +156,7 @@ def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args,
LOGGER.warning(
'Sleeping %.2f seconds before retry %d of %d for %s: %s %s, after %s',
sleep_time, retry_num, num_retries, req_type, method, uri,
resp.status if resp else exception)
resp.status if resp else Exception)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change loses the re-bound exception below, which means it loses information about the actual cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants