-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Exception handling ignored in minimal while loop #108214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can't reproduce:
|
I can't reproduce either, on Windows using 3.11.4. And dis.dis shows the same output for both. |
Well this is weird:
NB: I have checked 3.13 and it does not seem to have the interrupt issue anymore (even on my system). The interrupt issue also does not exist in 3.10 or 3.9. However the bytecode has NOPs starting in Python 3.10, including 3.13. |
I can reproduce it on my Debian machine with 3.11.4.
Disassembly:
|
The extra NOPs are expected, as they are necessary to preserve the line info correctly. They shouldn't result in the try/except being ignored. So a "repro" here should be "can (consistently, and even if waiting some time first) Ctrl-C without the except handler running," not just a difference in bytecode. The bytecode looks correct in both cases: the bytecodes included in the loop (covered by the |
I reproduced the bug (consistently never printing |
I can also repro on Linux debug build, latest 3.12 branch, (47f60c3). Because I think the correct fix in 3.11 and 3.12 is to move |
cc @gvanrossum since a partial backport of #104584 looks to be the right direction to fix this bug, and cc @Yhg1s since this is a fix that we probably ideally want in 3.12 final (though since the bug also exists in 3.11, it may not be strictly a blocker.) (EDIT: I messed up the link above, it's #106141 that may need a partial backport, and that's a @markshannon PR so I tagged the wrong person too :) ) |
Thinking more about it, I think this is not a release blocker. We can fix it in 3.12.1 and backport that fix to 3.11. @Yhg1s Agreed? (And yes, I can repro for 3.11 and 3.12 on macOS.) |
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
pass
into 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).
The text was updated successfully, but these errors were encountered: