[Python-Dev] TypeError and AttributeError
Guido van Rossum
guido@digicool.com
Wed, 11 Jul 2001 19:26:33 -0400
> >>>>>> "JA" == James Althoff <James_Althoff@i2.com> writes:
> >
> > JA> would it make sense to make AttributeError a subclass of
> > JA> TypeError so that
> >
> > JA> except (TypeError):
> >
> > JA> would become equally "safe" (and simpler)?
>
> [Barry]
>
> >No, but it /might/ make sense to give them a new common base class
> >between them and Exception. If so, called what?
>
> ProtocolException.
>
> I think it would have made sense, but it probably wouldn't have helped.
> Users still see a specific exception thrown and write code against that.
Yeah, the problem with Jim's proposal is that users who write
try:
"try something"
except TypeError:
"one way of handling it"
except AttributeError:
"another way of handling it"
will still see a change in behavior, as will users who catch
only AttributeError in a situation that now raises TypeError...
--Guido van Rossum (home page: http://www.python.org/~guido/)