You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove the 2to3 program and the lib2to3 module #104780
The 2to3 program is implemented with the lib2to3 module which implements a parser of the Python language. Problem: this parser is unable to parse Python 3.10 grammar :-( This issue was already known in Python 3.9 when PEP 617 – New PEG parser for CPython was approved.
The 2to3 program and the lib2to3 were marked as "pending" deprecated since Python 3.9, and then officially deprecated in Python 3.11 (import lib2to3 emits a DeprecationWarning).
One of a famous user of lib2to3 was the black project but they decided to fork lib2to3 and their fork was made compatible with Python 3.10 grammar (maybe also Python 3.11).
I propose to remove 2to3 and lib2to3 at the beginning of the Python 3.13 development cycle to give users more time to be prepared for this incompatible change before Python 3.13 final release (scheduled in October 2024).
with (open(__file__) asfp): data=fp.read()
print(len(data))
It works well on Python 3.11:
$ python3.11 script.py
61
But lib2to3 is unable to parse it:
$ python3.11 -m lib2to3 script.py
(...)
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse script.py: ParseError: bad input: type=1, value='as', context=(' ', (1, 21))
Activity
pythongh-104780: Remove 2to3 program and lib2to3 module
gh-104780: Remove 2to3 program and lib2to3 module (#104781)
vstinner commentedon May 23, 2023
Done by ae00b81
hugovk commentedon May 23, 2023
Wow!
(I think this issue can be closed, please re-open otherwise :)
vstinner commentedon May 24, 2023
lib2to3 was deprecated in Python 3.11 by issue #84540.
2to3 was removed from Python 3.13 (python/cpython#104780)
2to3 was removed from Python 3.13 (python/cpython#104780)
Merge pull request #22 from anaconda/2to3_was_removed
2to3 was removed from Python 3.13 (python/cpython#104780)