PEP 758: align unparenthesized-exception SyntaxError metadata with CPython · Issue #8496 · RustPython/RustPython · GitHub
Skip to content

PEP 758: align unparenthesized-exception SyntaxError metadata with CPython #8496

Description

@youknowone

Feature

PEP 758's valid unparenthesized except and except* forms work. The remaining incompatibility is the SyntaxError location/text metadata for invalid unparenthesized exception lists used with as.

Minimal reproduction:

src = """\
try:
    pass
except A, B, C as e:
    pass
"""

try:
    compile(src, "x.py", "exec")
except SyntaxError as exc:
    print(exc.msg)
    print(exc.args[1])

CPython 3.14.6:

multiple exception types must be parenthesized when using 'as'
('x.py', 3, 2, '\n', 3, 2)

RustPython:

multiple exception types must be parenthesized when using 'as'
('x.py', 3, 8, 'except A, B, C as e:\n', 3, 15)

The same location mismatch occurs for except* A, B, C as e:.

This issue is only about CPython-compatible exception metadata; valid PEP 758 syntax, runtime behavior, and ast.parse(..., feature_version=...) gating already work.

Python Documentation or reference to CPython source code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-compatA discrepancy between RustPython and CPython

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions