-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Given the following codes:
try:
...
except* Exception:
...
except Exception: # SyntaxError here
...
# but traceback point hereTraceback:
File "main.py", line 8
# but traceback point here
SyntaxError: cannot have both 'except' and 'except*' on the same 'try'
and:
try:
...
except* Exception:
...
except Exception: # SyntaxError here
...
def next_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
iritkatrielBlueGlassBlock
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error