Re-throwing an exception without loosing the stack trace

Chris Liechti cliechti at
Wed Feb 13 01:27:13 CET 2002

"Clark C . Evans" <cce at> wrote in 
news:mailman.1013552683.30067.python-list at

> How do I catch and then re-throw an exception without
> loosing the information about the stack trace?  I've
> looked around alot and don't see the "obvious" answer.

try a simple, naked "raise" ;-)

> Thanks!
> Clark
> P.S. I need to catch exceptions to clean up some
>      resources (database locked table), but
>      then I want to re-throw the error... in
>      it's original stack trace so that I can
>      find it... loosing the stack trace makes
>      for brutal debugging.

look at the traceback module too.
you can print out an exception with
"traceback.print_exc(file=sys.stderr)" and still continue your prog.
you can also save a copy of the stack trace with
"sys.exc_info()" and evaluate it later.


Chris <cliechti at>

More information about the Python-list mailing list