Skip to content

Conversation

@cclauss
Copy link

@cclauss cclauss commented Jul 3, 2018

Signed-off-by: cclauss [email protected]

What changes were proposed in this pull request?

Humans will be able to enter text in Python 3 prompts which they can not do today.
The Python builtin raw_input() was removed in Python 3 in favor of input(). This PR does the same thing in Python 2.

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
flake8 testing

Please review http://spark.apache.org/contributing.html before opening a pull request.

sys.exit(-1)

if sys.version < '3':
input = raw_input
Copy link
Member

Choose a reason for hiding this comment

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

If we can do the opposite, the diff should be only 4 lines though

Copy link
Author

Choose a reason for hiding this comment

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

Two downsides to that approach:

  1. We stick with the legacy Python syntax which will unnecessarily complicate our lives (and our diffs) in 18 months
  2. This approach reduces the linting errors from 10 down to just 2.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Are you actually able to roughly check if those scripts can be ran against Python 3?

@cclauss
Copy link
Author

cclauss commented Jul 3, 2018

Tested data entry...
In ./dev/merge_spark_pr.py just after clean_up(), I added the lines:

while not continue_maybe('y to conntinue'):
    print('loop')
sys.exit()

Test: 'y' or 'Y' caused a loop while all others including "", "yes", "n", "N", "0", "1", "." caused an exit()
Identical results on both Python 2 and Python 3


In ./dev/create-release/releaseutils.py just after _yesOrNoPrompt() I added the lines:

while not yesOrNoPrompt('y to quit'):
    print('got an 'n'')
sys.exit()

Test: 'y' caused an exit() while all others including "", "Y", "yes", "n", "N", "0", "1", "." caused a loop
Identical results on both Python 2 and Python 3

@HyukjinKwon
Copy link
Member

ok to test

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LGTM

@SparkQA
Copy link

SparkQA commented Jul 3, 2018

Test build #92570 has finished for PR 21702 at commit 960769a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Merged to master

@asfgit asfgit closed this in b42fda8 Jul 4, 2018
@cclauss cclauss deleted the python-fix-raw_input branch July 4, 2018 03:32
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.

3 participants