Skip to content

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

Description

@sobolevn

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

Activity

  1. self-assigned this
    on Apr 30, 2025
  2. added 2 commits that reference this issue on Apr 30, 2025
  3. cdce8p commented on May 2, 2025

    @cdce8p
    Contributor

    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.

  4. sobolevn commented on May 2, 2025

    @sobolevn
    MemberAuthor

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

  5. added a commit that references this issue on May 3, 2025
  6. added a commit that references this issue on Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixestopic-parsertype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions