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

Martin v. Loewis martin@v.loewis.de
27 Mar 2002 20:07:57 +0100


Guido van Rossum <guido@python.org> writes:

> http://python.org/sf/518846 reports that new-style classes cannot be > used as exceptions. I think it is desirable that this is fixed, but I > also believe that it conflicts with string exceptions.

Can you explain this conflict? Couldn't this be worked around by making an exception for strings?

Currently, if you write

try: raise "Hallo" except str: pass

the exception will pass through. If "new-style classes" (aka types) are allowed, then the string /should/ be caught.

I think string exceptions are used enough that we should deprecate them on a slower schedule.

If you follow Paul's rationale (exceptions should inherit from Exception), then the bug report could be closed, and no action would be needed until Exception becomes a type.

Regards, Martin