Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"SyntaxError: cannot have both 'except' and 'except*' on the same 'try'" traceback point to a confusing place #99153

Closed
Labels
3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@ProgramRipper

Description

@ProgramRipper

Bug report

Given the following codes:

try:    ...except*Exception:    ...exceptException:# SyntaxError here    ...# but traceback point here

Traceback:

  File "main.py", line 8    # but traceback point hereSyntaxError: cannot have both 'except' and 'except*' on the same 'try'

and:

try:    ...except*Exception:    ...exceptException:# SyntaxError here    ...defnext_scope():# but traceback point here    ...

Traceback:

  File "main.py", line 8    def next_scope(): # but traceback point here    ^^^SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

The traceback points to a confusing place (the last line of the file or the beginning of the next structure statement) rather than the location of the syntax error.
The traceback I expect is:

  File "main.py", line 5    except Exception: # SyntaxError here    ^^^^^^SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

Your environment

  • CPython versions tested on: 3.11.0
  • Operating system and architecture: Ubuntu 22.04 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp