[Python-Dev] Exceptions *must*? be old-style classes?
Phillip J. Eby
pje at telecommunity.com
Sun Jan 16 03:22:28 CET 2005
At 05:57 PM 1/15/05 -0800, Guido van Rossum wrote:
>It's been suggested that all exceptions should inherit from Exception,
>but this would break tons of existing code, so we shouldn't enforce
>that until 3.0. (Is there a PEP for this? I think there should be.)
Couldn't we require new-style exceptions to inherit from Exception? Since
there are no new-style exceptions that work now, this can't break existing
code. Then, the code path is just something like:
if isinstance(ob,Exception):
# it's an exception, use its type
else:
# all the other tests done now
This way, the other tests that would be ambiguous wrt new-style classes can
be skipped, but non-Exception classic classes would still be handled by the
existing checks.
Or am I missing something?
More information about the Python-Dev
mailing list