[Python-Dev] Deprecating string exceptions

Guido van Rossum guido@python.org
Wed, 27 Mar 2002 20:06:08 -0500


> "user-defined exceptions be derived from Exception". It is only a
> recommendation in the sense that you can use arbitrary classic
> classes. If the rule is eventually tightened, it is ok if new-style
> classes are not allowed as exceptions right now. An action is only
> needed if you pronounce that it is desirable to allow new-style
> classes as exceptions - which would necessarily have a base class
> that is not derived from Exception.

Well, in the long run I would like all classes to be new-style
classes, so at that point at the latest, exceptions will have to
follow.  Long before that moment, I would like to encourage people to
use new-style classes for everything, and that should include
exceptions.  (Also, at some point before the end state, the default
for a class statement would become to create a new-style class rather
than a classic class.)

This is somewhat separate from enforcing the "exceptions must derive
from Exception" rule.  We should start warning about string exceptions
as well as about class exceptions not deriving from Exception soon.
Whether Exception should become a new-style class before, after or at
the same time as full enforcement of that rule is an open issue.

(Barry, are you taking notes for the transition-to-all-exceptions-
deriving-from-Exception PEP?)

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