Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove the 2to3 program and the lib2to3 module #104780

Closed
@vstinner

Description

@vstinner

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 whenPEP 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 aDeprecationWarning).

One of a famous user of lib2to3 was theblack 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).

cc@isidentical@lysnikolaou@pablogsal@ambv


Example of valid Python script (script.py:

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))

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp