Windows Cmd.exe Window

Duncan Booth duncan.booth at invalid.invalid
Thu Jul 7 16:16:18 CEST 2005

harold fellermann wrote:

> sorry, I did not think. if you want to wait for input _only_ if
> an exception occured, your exit function needs to check for the
> exception:
> >>> import atexit
> >>>
> >>> def wait_on_exc() :
> ...     import sys
> ...     if sys.exc_type :
> ...         raw_input()
> ...
> >>> atexit.register(wait_on_exc)
> this should do the job, now.

Did you think to test your code before posting it?

sys.exc_type is deprecated (you should use sys.exc_info() instead), but 
neither will tell you whether the program is exiting as a result of an 
exception when called from an atexit function, by the time the atexit 
function is called the exception is no longer accessible.

As Larry Bates suggested, the OP needs to use a sys.excepthook. 
Unfortunately he doesn't test his code either (the parameter 'traceback' 
conflicts with the module 'traceback'), but at least the principle is 

More information about the Python-list mailing list