Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
More generally, the issue happens with all exceptions raised by other threads.
Run the code below and interrupt with ctrl+c.
# If part of a file, potentially more code before the loop. Traceback says -1 regardless.foriinrange(30000000):ifnoti%1000000:pass# Or any other operation here that is faster than iterating a million i values.
With the following traceback:
Traceback (mostrecentcalllast):File"/home/panta/issue.py",line-1,in<module>KeyboardInterrupt
The issue disappears as soon as we add just a bit more to the loop
foriinrange(30000000):ifnoti%1000000:# The 3.10 traceback points to this line.passpass# The 3.11 and 3.12 tracebacks point to this line.
Traceback (mostrecentcalllast):File"/home/panta/issue.py",line4,in<module>passKeyboardInterrupt
The issue persists whether running from the shell or as a file or even usingexec. It works the same inside functions/methods. It exists in 3.11 and 3.12 but not 3.10, across Windows and Linux.
- CPython versions tested on: 3.10.6 (no issue), 3.11.1 (issue), 3.11.4 (issue), 3.12.0rc1 (issue)
- Operating system and architecture: Windows 10 and Ubuntu 22.04.2 LTS (WSL)
Linked PRs
- gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop #108242
- [3.12] gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop (GH-108242) #108275
- [3.11] gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop #108326
- gh-107901: add the HAS_EVAL_BREAK instruction flag #108375
- gh-107901: synthetic jumps which are not at end of loop no longer check the eval breaker #113721
- gh-107901: jump leaving an exception handler doesn't need an eval break check #113943
- gh-107901: duplicate blocks with no lineno that have an eval break and multiple predecessors #113950
- gh-107901: guarantee_lineno_for_exits is not doing anything #114008
- gh-107901: compiler replaces POP_BLOCK instruction by NOPs before optimisations #114530
- gh-107901: make compiler inline basic blocks with no line number and no fallthrough #114750