sys.excepthook, getting traceback values

Larry Bates lbates at swamisoft.com
Fri Jul 23 17:23:25 CEST 2004


Here is what I use:

    import traceback
    #
    # Get traceback lines
    #
    tblines=traceback.format_exception(type, value, tb)

Basically this is what prints in an uncaught exception.
You can then print, write to file, etc.

HTH,
Larry Bates
Syscon, Inc.

"Josh Close" <narshe at gmail.com> wrote in message
news:mailman.754.1090591358.5135.python-list at python.org...
> When sys.excepthook is called, type, value and traceback are passed
> into it. How do I get the values of traceback?
>
> I've tried printing it, but I get the memory location. I'm gussing
> there are some methods to use on it.
>
> >From what I can tell the traceback that's passed in works differently
> from the module traceback.
>
> I just need to get the traceback to log it. I can use type and value,
> but that doesn't print what line the error occurred.
>
> -Josh





More information about the Python-list mailing list