sys.excepthook not working

Bernhard Herzog bh at intevation.de
Fri Feb 21 12:39:12 EST 2003


"Larry Bates" <lbates at swamisoft.com> writes:

> I have tried unsuccessfully to set my own function to handle uncaught
> exceptions.
> Below is a short test program that doesn't work as expected:
> 
> import sys
> def Myexcepthook(type, value, traceback):
>     print "in Myexcepthook"
>     import traceback

This import overwrites the parameter traceback so that you get the
attribute error:

[...]
>   File "C:\Python22\Lib\traceback.py", line 94, in extract_tb
>     f = tb.tb_frame
> AttributeError: 'module' object has no attribute 'tb_frame'

tb is to be the traceback module not the traceback parameter originally
passed to Myexcepthook.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/




More information about the Python-list mailing list