Skip to content

Commit 1e2fcac

Browse files
authored
bpo-32207: Improve tk event exception tracebacks in IDLE. (python#4703)
When tk event handling is driven by IDLE's run loop, a confusing and distracting queue.EMPTY traceback context is no longer added to tk event exception tracebacks. The traceback is now the same as when event handling is driven by user code. Patch based on a suggestion by Serhiy Storchaka.
1 parent 21255fc commit 1e2fcac

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

Lib/idlelib/run.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,17 @@ def main(del_exitfunc=False):
134134
# exiting but got an extra KBI? Try again!
135135
continue
136136
try:
137-
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
137+
request = rpc.request_queue.get(block=True, timeout=0.05)
138138
except queue.Empty:
139+
request = None
140+
# Issue 32207: calling handle_tk_events here adds spurious
141+
# queue.Empty traceback to event handling exceptions.
142+
if request:
143+
seq, (method, args, kwargs) = request
144+
ret = method(*args, **kwargs)
145+
rpc.response_queue.put((seq, ret))
146+
else:
139147
handle_tk_events()
140-
continue
141-
method, args, kwargs = request
142-
ret = method(*args, **kwargs)
143-
rpc.response_queue.put((seq, ret))
144148
except KeyboardInterrupt:
145149
if quitting:
146150
exit_now = True
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Improve tk event exception tracebacks in IDLE.
2+
When tk event handling is driven by IDLE's run loop, a confusing
3+
and distracting queue.EMPTY traceback context is no longer added
4+
to tk event exception tracebacks. The traceback is now the same
5+
as when event handling is driven by user code. Patch based on a
6+
suggestion by Serhiy Storchaka.

0 commit comments

Comments
 (0)