Getting Extended Exception Information

Duncan Booth me at
Wed Jul 21 10:21:14 CEST 2004

Benjamin Niemann <b.niemann at> wrote in
news:cdl694$jqu$1 at 

> Cy Edmunds wrote:
>> In an exception handler I can get the error message by just
>> converting the Exception to a string. How do I get the entire message
>> including the call stack information that I see printed out with an
>> uncaught exception? 
> what you are looking for is probably:
> import traceback
> try:
>    ...
> except:
>    stackdump = "".join(traceback.format_exception(sys.exc_type,
>              sys.exc_value, sys.exc_traceback))
>    print stackdump

Please note that sys.exc_type, sys.exc_value and sys.exc_traceback have 
been deprecated for a long time now (they are not thread-safe). Use 
sys.exc_info() instead.

More information about the Python-list mailing list