Reraise exception with modified stack

Scott David Daniels Scott.Daniels at Acm.Org
Thu Jun 23 14:21:10 EDT 2005


Nicolas Fleury wrote:
> Scott David Daniels wrote:
> 
>> How about dropping reraise and changing:
>>           reraise(...)
>> to:
>>           addinfo(...)
>>           raise
> 
> 
> It doesn't work, or at least it doesn't do what I want.  I want to keep 
> the same exception stack to be able to identify the original error.  I 
> would like to avoid also writing in the caller something like 
> sys.exc_info()[-1].
> 
> Regards,
> Nicolas

Have you tried it?  Looked to do what you described to me when I run a
sample.  Note that is an unadorned raise with no args.  The idea is to
simply modify the exception object and then use raise to carry the
whole original exception along as if not intercepted.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list