Skip to content

ast.parse() fails to handle "A[1:2, *l]" after it is parsed and unparsed. #4908

Description

@xiaxinmeng

See the following example, code_1 can be parsed normally with ast.parse(). Then we unparse the tree_1 and to parse the code again and it fails. This test program can work normally on CPython .

test.py

import ast
code_1= "A[1:2, *l]"
tree_1 = ast.parse(code_1) #work normally

code_2 = ast.unparse(tree_1)
print(code_2)   # str "A[1:2, *l]"
tree_2 = ast.parse(code_2)  #fail

Expected output: work normally

Actual output:

Traceback (most recent call last):
  File "/home/xxm/Desktop/RustPython/test.py", line 345, in <module>
    tree_2 = ast.parse(code_2)  #fail
  File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/471ec26/pylib/Lib/ast.py", line 51, in parse
    _feature_version=feature_version)
SyntaxError: invalid syntax. Got unexpected token ':' at line 1 column 5
A[(1:2, *l)]
    ^

Environment
Ubuntu 18.04
RustPython 0.2.0
CPython 3.11.3

Activity

  1. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    The originally reported problem no longer reproduces on current main. Closing per the recheck in #8982.

    — commented by Grok 4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions