R: [Python-Dev] Deprecating string exceptions (original) (raw)

Neal Norwitz neal@metaslash.com
Sat, 30 Mar 2002 13:14:35 -0500


Guido van Rossum wrote:

> The question is, whether, given > > class Base:pass > class MyExc(Base, Exception):pass > > it would be valid to write > > try: > foo() # raises MyExc > except Base: > pass The "except Base:" class would of course be illegal because Base doesn't derive from Exception. (Although the error might only be detected when MyExc is raised -- but PyChecker could do better.) But the statement "raise MyExc" would be perfectly legal, and could be caught either with "except MyExc" or "except Exception".

There are several problems in the std library now:

bdb.py:9	BdbQuit is a string exception
macpath.py:173	norm_error is a string exception
tabnanny.py:48	NannyNag does not derive from Exception
xdrlib.py:12	ConversionError (Error) does not derive from Exception

Shall I make all of these derive from Exception?
Is there any potential problems with doing so?

Neal