[Python-Dev] Idea for avoiding exception masking

Aahz aahz@pythoncraft.com
Wed, 29 Jan 2003 10:35:13 -0500


On Wed, Jan 29, 2003, Barry A. Warsaw wrote:
> >>>>> "KY" == Ka-Ping Yee <ping@zesty.ca> writes:
> 
>     >> Python code has a number of cases where a higher level routine
>     >> traps an exception and reraises it with new information and
>     >> losing the lower level error detail in the process.
> 
>     KY> How about just holding on to the original exception and
>     KY> storing it as an attribute (e.g. "cause") on the new
>     KY> exception?
> 
> +1.  You may actually have a chain of exceptions so being able to
> follow these using a well-known attribute is a good thing.

This sounds good to me.  Not being the person most familiar with frames
and exceptions, though, I'm wondering what effects (if any) this will
have on unexpected retention of local names.
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach