Bug report
Checklist
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
No response
A clear and concise description of the bug:
Consider the following codeblock that works correctly when interrupted by ctrl+c.
try:
while 1:
pass
except KeyboardInterrupt:
print("Exception handling works!")
Exception handling works!
Now we push the pass into the same line and suddenly our try-except is ignored entirely:
try:
while 1: pass
except KeyboardInterrupt:
print("Exception handling works!")
Traceback (most recent call last):
File "/home/panta/issue.py", line 2, in <module>
while 1: pass
KeyboardInterrupt
This was quite a surprise to me because I naively expected both approaches to emit the same bytecode (except with different line info).
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
No response
A clear and concise description of the bug:
Consider the following codeblock that works correctly when interrupted by ctrl+c.
Now we push the
passinto the same line and suddenly our try-except is ignored entirely:This was quite a surprise to me because I naively expected both approaches to emit the same bytecode (except with different line info).