[Python-Dev] Exception masking/chaining
Walter Dörwald
walter@livinglogic.de
Thu, 12 Jun 2003 12:44:19 +0200
Greg Ewing wrote:
> Guido:
>
>>More globals of course defeat the purpose (one of the reasons for
>>putting the traceback in the exception is to get rid of
>>sys.exc_traceback).
>
> I think the idea was that this would be a C-level global,
> not a Python one (i.e. part of the existing group of
> C variables representing the current exception state).
Exactly. We'd only need this as sys.exc_cause, if we implemented
exception chaining before moving the traceback into the exception.
So maybe the plan should look somethink like this:
1. Deprecate string exceptions.
2. Make Exception a new-style class.
3. Require exceptions to be derived from Exception.
4. Make the traceback an attribute of the exception object.
5. Implement exception chaining (as an attribute named cause on
the outer exception referencing the inner exception).
6. Add other exception attributes (e.g. KeyError has an attribute
key, IndexError has an attribute index, IOError has attributes
filename, errorcode etc.)
Is there anything else that should go into the new exception PEP?
(No, I'm not volunteering to write it. ;) Maybe it should be split
into multiple PEPs?)
> [...]
Bye,
Walter Dörwald