sys.excepthook, getting traceback values

brianc at temple.edu brianc at temple.edu
Fri Jul 23 16:11:15 CEST 2004


The function I typically use for debugging purposes. Hope it
helps.

import traceback, cStringIO
def print_exception():
    f=cStringIO.StringIO()
    traceback.print_exc(100,f)
    s=f.getvalue()
    return s


---- Original message ----
>Date: Fri, 23 Jul 2004 09:02:36 -0500
>From: Josh Close <narshe at gmail.com>  
>Subject: sys.excepthook, getting traceback values  
>To: PYTHON <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
>-- 
>http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list