This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: use int() instead of long()
ClosedPublic

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

Details

Summary

Use int() rather than long() to interpret a string as a long integer
since Python 3's integer are long by default. This was produced by
running futurize's stage2 lib2to3.fixes.fix_long.

Diff Detail

Repository
rL LLVM

Event Timeline

thopre created this revision.Sep 20 2019, 1:35 AM
lnt/tests/compile.py
532 ↗(On Diff #220974)

Is this okay for 32-bit Python 2?

thopre marked 2 inline comments as done.Sep 21 2019, 7:51 AM
thopre added inline comments.
lnt/tests/compile.py
532 ↗(On Diff #220974)

According to the Conservative Python 3 Porting Guide [1]:

In Python 2, calling int on a number that doesn’t fit in the machine int range would automatically create a long with the appropriate value.

[1] https://portingguide.readthedocs.io/en/latest/numbers.html

So yes this should be safe.

hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added inline comments.
lnt/tests/compile.py
532 ↗(On Diff #220974)

Thanks for checking. LGTM.

This revision is now accepted and ready to land.Sep 21 2019, 7:59 AM
This revision was automatically updated to reflect the committed changes.
thopre marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptSep 25 2019, 12:51 AM