This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Bugs of 2to3 on built-in function or types(classes)
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, gregory.p.smith, prasechen
Priority: normal Keywords:

Created on 2022-02-04 14:49 by prasechen, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg412508 - (view) Author: chen-y0y0 (prasechen) Date: 2022-02-04 14:49
I have a file named foo.py:
try :
    input = raw_input
    int = long
    chr = unichr
    range = xrange
except NameError :
    pass

When I process this file to 2to3, it shows:
--- foo.py (original)
+++ foo.py (refactored)
@@ -1,7 +1,7 @@
 try :
     input = raw_input
-    int = long
-    chr = unichr
+    int = int
+    chr = chr
     range = xrange
except NameError :
    pass
RefactoringTool: Files that need to be modified:
RefactoringTool: foo.py

I don't know why it modifies the Python 2.x and 3.x compatible code.
msg412509 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2022-02-04 15:25
I'm not sure what you're trying to accomplish here, but long and unichr are not available in python 3.

2to3 has been deprecated and is no longer supported.
msg412518 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2022-02-04 16:57
lib2to3 is going away per https://bugs.python.org/issue40360

but it is behaving as intended above, it does not understand logic.  it was only ever intended to maybe work on python 2-only code.  not python 2-and-3 compatible code.
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90794
2022-02-04 16:57:02gregory.p.smithsetstatus: open -> closed

nosy: + gregory.p.smith
messages: + msg412518

resolution: not a bug
stage: resolved
2022-02-04 15:25:29eric.smithsetnosy: + eric.smith
messages: + msg412509
2022-02-04 14:49:59prasechensettitle: Bugs of 2to3 -> Bugs of 2to3 on built-in function or types(classes)
2022-02-04 14:49:36prasechencreate