
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-12-04 01:47 byterry.reedy, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4703 | merged | terry.reedy,2017-12-04 20:07 | |
| PR 4705 | merged | python-dev,2017-12-04 21:17 | |
| Messages (5) | |||
|---|---|---|---|
| msg307534 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2017-12-04 01:47 | |
import tkinter as tkroot = tk.Tk()def bad(): print(a, 'bad')def good(): print('good')root.after(1000, bad)root.after(1500, good)root.mainloop()# Correctly gives this traceback and output:Exception in Tkinter callbackTraceback (most recent call last): File "C:\Programs\Python37\lib\tkinter\__init__.py", line 1699, in __call__ return self.func(*args) File "C:\Programs\Python37\lib\tkinter\__init__.py", line 745, in callit func(*args) File "F:\Python\a\tem2.py", line 13, in bad def bad(): print(a, 'bad')NameError: name 'a' is not definedgood>>> ====================================Remove or comment-out the blocking 'root.mainloop()' call and run the result from an IDLE editor. The callbacks are still called because after user code is run, run.py calls tcl.update in a loop nominally 20 x per second. This allows developers to interact with a 'live' gui by entering statements in the shell at '>>>' prompts. The result is this.------------->>> Exception in Tkinter callbackTraceback (most recent call last): File "C:\Programs\Python37\lib\idlelib\run.py", line 137, in main seq, request = rpc.request_queue.get(block=True, timeout=0.05) File "C:\Programs\Python37\lib\queue.py", line 169, in get raise Emptyqueue.EmptyDuring handling of the above exception, another exception occurred:Traceback (most recent call last):<The NameError traceback and message, as before.>--------------The relevant code in run.py was written before callback chaining. try: seq, request = rpc.request_queue.get(block=True, timeout=0.05) except queue.Empty: handle_tk_events() continueExperiments with normal exceptions in a shell suggest that wrapping handle_tk_events in try:except and re-raising any exception 'from None' should work. try: handle_tk_events() except BaseException as e: raise e from NoneHowever, it appears that callback errors resulting from handle_tk_events() are not being caught here. (print('message') and 1/0 before 'raise' have no visible effect.) I will investigate more later. | |||
| msg307541 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-12-04 06:17 | |
try: seq, request = rpc.request_queue.get(block=True, timeout=0.05) except queue.Empty: request = None if request is None: handle_tk_events() continue | |||
| msg307594 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2017-12-04 20:12 | |
Thanks. I am still puzzled why the nested within nested try-except did not work as I expected, but I care more about fixing this. The result based on your suggestion is better (to read, I think) than extra nesting that did work. | |||
| msg307597 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2017-12-04 21:16 | |
New changeset1e2fcac4972530aa2c963d7e4011021df5ba866e by Terry Jan Reedy in branch 'master':bpo-32207: Improve tk event exception tracebacks in IDLE. (#4703)https://github.com/python/cpython/commit/1e2fcac4972530aa2c963d7e4011021df5ba866e | |||
| msg307599 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2017-12-04 22:02 | |
New changeset9da33c82124f27eb58ba4cf145675fe7a1035744 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':bpo-32207: Improve tk event exception tracebacks in IDLE. (GH-4703) (#4705)https://github.com/python/cpython/commit/9da33c82124f27eb58ba4cf145675fe7a1035744 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:55 | admin | set | github: 76388 |
| 2017-12-04 22:04:00 | terry.reedy | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-12-04 22:02:34 | terry.reedy | set | messages: +msg307599 |
| 2017-12-04 21:17:26 | python-dev | set | pull_requests: +pull_request4617 |
| 2017-12-04 21:16:20 | terry.reedy | set | messages: +msg307597 |
| 2017-12-04 20:34:02 | terry.reedy | set | stage: needs patch -> patch review |
| 2017-12-04 20:12:32 | terry.reedy | set | messages: +msg307594 stage: patch review -> needs patch |
| 2017-12-04 20:07:31 | terry.reedy | set | keywords: +patch stage: needs patch -> patch review pull_requests: +pull_request4615 |
| 2017-12-04 06:17:05 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg307541 |
| 2017-12-04 01:47:39 | terry.reedy | set | title: IDLE: run's tk update adds extra traceback on callback error -> IDLE: run's tk update adds context traceback on callback error |
| 2017-12-04 01:47:09 | terry.reedy | create | |