Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Traceback says line -1 when KeyboardInterrupt during minimal for-if-loop #107901

Closed
Assignees
iritkatriel
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error
@pan324

Description

@pan324

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

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp