[Python-Dev] Deprecating string exceptions
Barry A. Warsaw
Sat, 6 Apr 2002 01:03:55 -0500
>>>>> "JH" == Jeremy Hylton <email@example.com> writes:
JH> I'm not sure what the base class(es) actually buys us. We
JH> could just as well say by fiat that the interpreter will set
JH> the traceback attribute of an exception instance to the
JH> traceback. Why do we need a special base class to accomplish
JH> that? This is Python. You don't need to do isinstance().
JH> You just need to see if it has the right attributes.
You might be right. It certainly hasn't hindered us up 'til now.
JH> BTW, what is the signature for Exception.__init__()? I've
JH> written many exception classes, often subclasses of some other
JH> exception, but I've hardly ever paid attention to the
JH> superclass __init__(). It usually suffices to set the right
When it was written in Python, I believe it was defined as
def __init__(self, *args):
self.args = args
and that's essentially what it is now that it's implemented in C. But
many of the derived exception classes have their own funky
__init__()s for backwards compatibility, e.g. EnvironmentError which
looks at the number of arguments to decide which of the errno,
strerror, and filename attributes to set.