Issue 15262: Idle does not show traceback in other threads (original) (raw)

Created on 2012-07-06 08:28 by Mark, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg164718 - (view) Author: (Mark) Date: 2012-07-06 08:28
Consider the following code: from thread import start_new def f(): typo #there is no variable called typo start_new(f, ()) If run from the command line, this produces a traceback. If run from IDLE, it does not. I suspect this is not by design. This caused me endless grief in debugging until one happy day I discovered the traceback module. I now write: from thread import start_new from traceback import print_exc def f(): try: typo except: print_exc() start_new(f, ()) this works, but I wish I didn't need it.
msg164777 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-07-07 03:01
In 3.3, you do not need it >>> Unhandled exception in thread started by <function f at 0x00000000031D0158> Traceback (most recent call last): File "F:\Python\mypy\tem.py", line 2, in f def f(): typo #there is no variable called typo NameError: global name 'typo' is not defined In 3.2 only the first line is printed; the traceback is not. The change is due to recent internal improvements in core Python 3 exception handling. (In 3.x, thread was renamed _thread to discourage its direct use and to encourage use of threading instead. I tested with _thread.)
msg164787 - (view) Author: (Mark) Date: 2012-07-07 05:59
So, I should not hold my breath in the hope of this being fixed in 2.7?
msg165028 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-07-08 17:30
Unless this could have been just as easily fixed in IDLE as in the core (Roger?), no, don't hold your breath ;-).
msg165051 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-07-09 01:04
Mark, I ran your example against 2.7.1 and did not receive a traceback. I then ran it against the latest 2.7.3+ and receive a traceback in IDLE. Here's the entire Shell contents: Python 2.7.3+ (2.7:97445ca895d5, Jul 8 2012, 19:58:43) [GCC 4.5.2] on linux2 Type "copyright", "credits" or "license()" for more information. >>> from thread import start_new >>> def f(): typo >>> start_new(f, ()) 139804918241024Unhandled exception in thread started by <function f at 0x1e36050> >>> Traceback (most recent call last): File "<pyshell#2>", line 1, in f NameError: global name 'typo' is not defined >>>
msg165056 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-07-09 03:17
Thanks Roger. So this should be fixed in the upcoming 2.7.4 and probably 3.2.4.
msg165085 - (view) Author: (Mark) Date: 2012-07-09 14:40
Yay! I can't wait :)
History
Date User Action Args
2022-04-11 14:57:32 admin set github: 59467
2012-07-09 14:40:25 Mark set messages: +
2012-07-09 03:17:18 terry.reedy set messages: +
2012-07-09 01:04:37 roger.serwy set messages: +
2012-07-08 17:30:05 terry.reedy set nosy: + roger.serwymessages: +
2012-07-07 05:59:45 Mark set messages: +
2012-07-07 03:01:16 terry.reedy set status: open -> closednosy: + terry.reedymessages: + resolution: fixedstage: resolved
2012-07-06 08:28:12 Mark create