[Python-Dev] Tidier Exceptions
Brett C.
bac at OCF.Berkeley.EDU
Fri May 13 01:42:46 CEST 2005
Guido van Rossum wrote:
> [Ka-Ping Yee]
>
>>It occurred to me as i was messing around with handling and re-raising
>>exceptions that tossing around these (type, value, traceback) triples
>>is irritating and error-prone.
>>
>>How about just passing around a single value? All we'd have to do is
>>put the traceback in value.traceback.
>
>
> I proposed the same thing a while back (during the early hours of
> writing PEP 340).
>
> It won't fly as long as we have string exceptions (since there's
> nowhere to put the traceback) but once those are dead I like it a lot.
>
Seems like, especially if we require inheritance from a base exception class in
Python 3000, exceptions should have standard 'arg' and 'traceback' attributes
with a possible 'context' attribute (or always a 'context' attribute set to
None if not a chained exception).
I don't think there is other data normally associated with exceptions is there?
I really need to get off my ass one of these days and just write a PEP targeted
for Python 3000 with base inheritance, standard attributes (including exception
chains), reworking the built-in exception inheritance hierarchy, and whether
bare 'except' statements should go or only catch certain exceptions. Could
probably stand to break it up until multiple PEPs, though. =)
-Brett
More information about the Python-Dev
mailing list