How can an Exception pass over an "except" clause ?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed May 30 14:52:59 EDT 2007


En Wed, 30 May 2007 15:30:43 -0300, Nebur <nospam1.reifenberg at gmx.de>  
escribió:

> @Tijs: I think when re-raising, the backtrace will always point to the
> line where it was re-raised but not to line 1265. (Or can we re-raise
> an exception so that it preserves the backtrace of the "original"
> exception?)

I think Tijs is right. raise (with no arguments) will raise the *last*  
exception, not the one that was active when you entered the except clause;  
it preserves the traceback.
Either replace the inner try/except using getattr, or save the full  
exception details (including traceback) and use the 3-argument form of the  
raise statement.
See http://docs.python.org/ref/raise.html

-- 
Gabriel Genellina




More information about the Python-list mailing list