Title: ast.parse() fails to handle "A[1:2, *l]" after it is parsed and unparsed. · Issue #4908 · RustPython/RustPython · GitHub
Open Graph Title: ast.parse() fails to handle "A[1:2, *l]" after it is parsed and unparsed. · Issue #4908 · RustPython/RustPython
X Title: ast.parse() fails to handle "A[1:2, *l]" after it is parsed and unparsed. · Issue #4908 · RustPython/RustPython
Description: 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...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/RustPython/RustPython/issues/4908
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ast.parse() fails to handle \"A[1:2, *l]\" after it is parsed and unparsed.","articleBody":"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 . \r\n\r\ntest.py\r\n```\r\nimport ast\r\ncode_1= \"A[1:2, *l]\"\r\ntree_1 = ast.parse(code_1) #work normally\r\n\r\ncode_2 = ast.unparse(tree_1)\r\nprint(code_2) # str \"A[1:2, *l]\"\r\ntree_2 = ast.parse(code_2) #fail\r\n```\r\n\r\nExpected output: work normally\r\n\r\n\r\nActual output:\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/xxm/Desktop/RustPython/test.py\", line 345, in \u003cmodule>\r\n tree_2 = ast.parse(code_2) #fail\r\n File \"/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/471ec26/pylib/Lib/ast.py\", line 51, in parse\r\n _feature_version=feature_version)\r\nSyntaxError: invalid syntax. Got unexpected token ':' at line 1 column 5\r\nA[(1:2, *l)]\r\n ^\r\n```\r\n\r\nEnvironment\r\nUbuntu 18.04\r\nRustPython 0.2.0\r\nCPython 3.11.3","author":{"url":"https://github.com/xiaxinmeng","@type":"Person","name":"xiaxinmeng"},"datePublished":"2023-04-21T06:26:11Z","url":"https://github.com/RustPython/RustPython/issues/4908"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4f886857-9959-87ca-7305-704b2162cfb4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B768:59CDA:2F91D16:3E94383:6B002718 |
| html-safe-nonce | b41cacee32cf352eaa038bb54be786b0b4dd8e6323af610ea743b9330e07f585 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzY4OjU5Q0RBOjJGOTFEMTY6M0U5NDM4Mzo2QjAwMjcxOCIsInZpc2l0b3JfaWQiOiIyNDA4NDgwMTEwNzY5MzUwNDI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7324af00af19930e2b366283dba1888e8caadb01530875f723a460430b4126e7 |
| hovercard-subject-tag | issue:1677907351 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/4908/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e0588a6aa8eb92718b6e9776be7b5cb10ef9dee66d7e6afb0fa65706f0a5d9a4/RustPython/RustPython/issues/4908 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e0588a6aa8eb92718b6e9776be7b5cb10ef9dee66d7e6afb0fa65706f0a5d9a4/RustPython/RustPython/issues/4908 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | xiaxinmeng |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width