Skip to content

Fix next(), print(), and raw_input() to work in Python 2 and 3 - #5599

Merged
htuch merged 1 commit into
envoyproxy:masterfrom
cclauss:modernize-Python-2-codes
Jan 16, 2019
Merged

htuch merged 1 commit into
envoyproxy:masterfrom
cclauss:modernize-Python-2-codes

Conversation

@cclauss

@cclauss cclauss commented Jan 14, 2019 •

Copy link
Copy Markdown
Contributor

Related to #4552

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

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Description: Resolves syntax errors and name errors that have the potential to halt the runtime.
Risk Level: Minimal
Testing: http://flake8.pycqa.org
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

@cclauss
cclauss force-pushed the modernize-Python-2-codes branch from b05dc82 to dc414f2 Compare January 14, 2019 18:52
@lizan
lizan requested a review from htuch January 14, 2019 20:52

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @cclauss, this is great. Can you also add to the description that this relates to #4552?

Are you interested in owning #4552?

Comment thread tools/check_format_test_helper.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you be consistent in putting a separating blank line between the __future__ imports and the rest? I think the space makes sense, but it's not done everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the scope of this PR is more than just print, it seems general Python 3 compat, can you update the description?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

…hon 3

Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.

Signed-off-by: cclauss <[email protected]>
@cclauss
cclauss force-pushed the modernize-Python-2-codes branch from 93bb9a0 to b3ab77e Compare January 15, 2019 08:12
@cclauss cclauss changed the title Use print() function in both Python 2 and Python 3 Fix next(), print(), and raw_input() to work in both Python 2 and 3 Jan 15, 2019
@cclauss cclauss changed the title Fix next(), print(), and raw_input() to work in both Python 2 and 3 Fix next(), print(), and raw_input() to work in Python 2 and 3 Jan 15, 2019

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@htuch
htuch merged commit abd82f7 into envoyproxy:master Jan 16, 2019
@cclauss
cclauss deleted the modernize-Python-2-codes branch January 16, 2019 06:18
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
…hon 3 (envoyproxy#5599)

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

Resolves syntax errors and name errors that have the potential to halt the runtime.

Risk Level: Minimal
Testing: http://flake8.pycqa.org

Signed-off-by: cclauss <[email protected]>
Signed-off-by: Fred Douglas <[email protected]>
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.

2 participants