mirror of
https://github.com/python/cpython.git
synced 2026-10-28 18:35:21 +08:00
gh-71136: Fix IDLE Shell hang after KeyboardInterrupt under the debugger (#157566)
Debugging 'raise KeyboardInterrupt' in debugged code no longer hangs IDLE forever. The response is similar to without the debugger. --------- Co-authored-by: Louie Lu <git@louie.lu> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2 files changed
+8
-1
No files matched your search
+6
-1
@@ -164,6 +164,7 @@ def main(del_exitfunc=False):
|
||||
).start()
|
||||
|
||||
while True:
|
||||
request = None
|
||||
try:
|
||||
if exit_now:
|
||||
try:
|
||||
@@ -174,9 +175,9 @@ def main(del_exitfunc=False):
|
||||
try:
|
||||
request = rpc.request_queue.get(block=True, timeout=0.05)
|
||||
except queue.Empty:
|
||||
request = None
|
||||
# Issue 32207: calling handle_tk_events here adds spurious
|
||||
# queue.Empty traceback to event handling exceptions.
|
||||
pass
|
||||
if request:
|
||||
seq, (method, args, kwargs) = request
|
||||
ret = method(*args, **kwargs)
|
||||
@@ -186,6 +187,10 @@ def main(del_exitfunc=False):
|
||||
except KeyboardInterrupt:
|
||||
if quitting:
|
||||
exit_now = True
|
||||
elif request:
|
||||
# Interrupted while executing a request, as when debugging.
|
||||
print_exception()
|
||||
rpc.response_queue.put((seq, None))
|
||||
continue
|
||||
except SystemExit:
|
||||
capture_warnings(False)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Fix a hang of the IDLE Shell when code run under the debugger raises
|
||||
:exc:`KeyboardInterrupt`.
|
||||
Reference in new issue
Block a user