R: [Python-Dev] Deprecating string exceptions

Guido van Rossum guido@python.org
Thu, 28 Mar 2002 10:33:47 -0500


> Guido van Rossum <guido@python.org> writes:
> 
> > I can't see any implementation benefits from the requirement.  It
> > sounds like you can't either
> 
> If the requirement was extended to disallow multiple root classes, it
> would disambiguate the case of the class Z(str,Exception): It would be
> an error to raise an exception of class Z. Classes that only inherit
> from str would continue to operate as string exceptions, classes that
> inherit from Exception would be caught by their type - you couldn't
> have a class that is both.
> 
> Regards,
> Martin

Yeah, but that's only a backwards compatibility hack.  Eventually,
string exceptions will be illegal, and then I don't see a good reason
why exceptions couldn't derive from multiple classes.  So I don't want
to start with such a restriction.  I'd rather continue to special-case
string exceptions.

There's no reason why in your example, the exception couldn't match
both Exception and a string.

--Guido van Rossum (home page: http://www.python.org/~guido/)