[Python-checkins] bpo-32207: Improve tk event exception tracebacks in IDLE. (GH-4703) (#4705)

Terry Jan Reedy webhook-mailer at python.org
Mon Dec 4 17:02:36 EST 2017


https://github.com/python/cpython/commit/9da33c82124f27eb58ba4cf145675fe7a1035744
commit: 9da33c82124f27eb58ba4cf145675fe7a1035744
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Terry Jan Reedy <tjreedy at udel.edu>
date: 2017-12-04T17:02:32-05:00
summary:

bpo-32207: Improve tk event exception tracebacks in IDLE. (GH-4703) (#4705)

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.
(cherry picked from commit 1e2fcac4972530aa2c963d7e4011021df5ba866e)

files:
A Misc/NEWS.d/next/IDLE/2017-12-04-15-04-43.bpo-32207.IzyAJo.rst
M Lib/idlelib/run.py

diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 6440e673bf5..176fe3db743 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -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
diff --git a/Misc/NEWS.d/next/IDLE/2017-12-04-15-04-43.bpo-32207.IzyAJo.rst b/Misc/NEWS.d/next/IDLE/2017-12-04-15-04-43.bpo-32207.IzyAJo.rst
new file mode 100644
index 00000000000..e521c9b0bbd
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2017-12-04-15-04-43.bpo-32207.IzyAJo.rst
@@ -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.



More information about the Python-checkins mailing list