Closed
Description
Bug report
Given the following codes:
try: ... except* Exception: ... except Exception: # SyntaxError here ... # but traceback point here
Traceback:
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