Skip to content

PEP 758 changes do not have CHECK_VERSION guard for usage with ast.parse(..., feature_version=(3, 13)) #133194

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

Closed
sobolevn opened this issue Apr 30, 2025 · 2 comments · Fixed by #133289
Assignees
Labels
3.14 bugs and security fixes topic-parser type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Apr 30, 2025

Bug report

Right now this test passes:

    def test_pep758_except_without_parens(self):
        code = textwrap.dedent("""
            try:
                ...
            except ValueError, TypeError:
                ...
        """)
        ast.parse(code, feature_version=(3, 14))
        with self.assertRaises(SyntaxError):
            ast.parse(code, feature_version=(3, 13))

But, it should not pass. I have a PR ready.

Linked PRs

@sobolevn sobolevn added 3.14 bugs and security fixes topic-parser type-bug An unexpected behavior, bug, or error labels Apr 30, 2025
@sobolevn sobolevn self-assigned this Apr 30, 2025
sobolevn added a commit to sobolevn/cpython that referenced this issue Apr 30, 2025
@cdce8p
Copy link
Contributor

cdce8p commented May 2, 2025

The fix in #133195 broke valid cases. E.g.

import ast
import textwrap

code = textwrap.dedent("""
    try:
        ...
    except ValueError:
        ...
""")
ast.parse(code, feature_version=(3, 10))

now also raises a SyntaxError.

@sobolevn
Copy link
Member Author

sobolevn commented May 2, 2025

@sobolevn oups, indeed. thanks for noticing. working on a fix

@sobolevn sobolevn reopened this May 2, 2025
sobolevn added a commit that referenced this issue May 3, 2025
…ion` (#133289)

gh-133192: Fix regression with PEP 758 parsing on older `feature_version`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes topic-parser type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants