Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent ast.parse result for python<3.11 and PEP654 #96587

Closed
sobolevn opened this issue Sep 5, 2022 · 2 comments
Closed

Inconsistent ast.parse result for python<3.11 and PEP654 #96587

sobolevn opened this issue Sep 5, 2022 · 2 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 5, 2022

PEP654 introduced exception groups and except* in python3.11
Link: https://peps.python.org/pep-0654/

Right now it is possible to parse except* with older ast.parse(..., feature_version=(3, 10)).
Example:

>>> import ast
>>> code = '''
... try:
...   ...
... except* Exception:
...   ...
... '''
>>> 
>>> ast.parse(code)
<ast.Module object at 0x10c685410>
>>> ast.parse(code, feature_version=(3, 8))
<ast.Module object at 0x10c685280>
>>> 

Which is not correct.

But, unlike #96427 it is very simple to fix. And I belive it should be fixed.

I've already applied a patch and will send it shortly after :)

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 5, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 5, 2022
@pablogsal
Copy link
Member

Thanks for the PR!

sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 5, 2022
…re_version` (pythonGH-96588).

(cherry picked from commit 2c7d2e8)

Co-authored-by: Nikita Sobolev <[email protected]>
ambv pushed a commit that referenced this issue Oct 5, 2022
…sion` (GH-96588) (#96591)

(cherry picked from commit 2c7d2e8)

Co-authored-by: Nikita Sobolev <[email protected]>
@iritkatriel
Copy link
Member

This is resolved now, right?

@sobolevn sobolevn closed this as completed Oct 7, 2022
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…sion` (GH-96588) (#96591)

(cherry picked from commit 2c7d2e8)

Co-authored-by: Nikita Sobolev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants