Skip to content

Commit

Permalink
bpo-32207: Improve tk event exception tracebacks in IDLE. (#4703)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
terryjreedy authored Dec 4, 2017
1 parent 21255fc commit 1e2fcac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Lib/idlelib/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ def main(del_exitfunc=False):
# exiting but got an extra KBI? Try again!
continue
try:
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
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.
if request:
seq, (method, args, kwargs) = request
ret = method(*args, **kwargs)
rpc.response_queue.put((seq, ret))
else:
handle_tk_events()
continue
method, args, kwargs = request
ret = method(*args, **kwargs)
rpc.response_queue.put((seq, ret))
except KeyboardInterrupt:
if quitting:
exit_now = True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Improve tk event exception tracebacks in IDLE.
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.

0 comments on commit 1e2fcac

Please sign in to comment.