This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: adapt to renaming of raw_input to input
ClosedPublic

Authored by thopre on Sep 20 2019, 1:37 AM.

Details

Summary

Replace calls to raw_input by calls to input() which is not evaluated as
an expression in Python3. Import input from builtins to maintain
current behavior on Python2. This was produced by running
futurize's stage2 lib2to3.fixes.fix_raw_input.

Event Timeline

thopre created this revision.Sep 20 2019, 1:37 AM

I don't see how this maintains compatibility with Python 2.

I believe adding this to the files should work:

try:
    from builtins import input as raw_input
except ImportError:
    pass
thopre updated this revision to Diff 221200.Sep 21 2019, 2:27 PM

Import input from builtins for input to behave like raw_input in Python 2

I believe adding this to the files should work:

try:
    from builtins import input as raw_input
except ImportError:
    pass

The import from builtins without renaming ought to be sufficient. It basically means input on Python2 behaves like raw_input. It's weird that 2to3's fix_raw_input did this transformation without adding the import. I'm glad you were more careful evaluating the change than me.

thopre edited the summary of this revision. (Show Details)Sep 21 2019, 2:34 PM
lnt/external/stats/stats.py
227

This is dependent on the "future" package. I guess the update to the package dependency list needs to move earlier in patch set to this patch?

thopre updated this revision to Diff 221305.Sep 23 2019, 5:28 AM

Add dependency on future

This revision is now accepted and ready to land.Sep 23 2019, 6:32 AM
thopre closed this revision.Sep 25 2019, 1:17 AM