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
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
Expected output: work normally
Actual output:
Environment
Ubuntu 18.04
RustPython 0.2.0
CPython 3.11.3