[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Include rangeobject.h,2.16,2.17

Guido van Rossum guido@digicool.com
Sun, 08 Jul 2001 20:40:47 -0400

> On 08 July 2001, Guido van Rossum said:
> > Q. If an operation that failed with an AttributeError now fails with a
> > TypeError (or the other way around), how important is that
> > incompatibility?

Greg Ward:
> I generally think of those exceptions as meaning, "You've got a bug in
> your code, bozo" so I don't bother catching them (except in the main
> loop of GUIs and servers, to show a big scary traceback to the poor user
> or dump it in a logfile).

That's my view on them too.

> However, I think that AttributeError is pretty aptly used for the most
> part, and I don't see a great benefit in changing an incorrect
> "thing.property" to raise TypeError.

Fortunately, that wasn't what I attempted to propose.  As I mentioned
in my reply to Fredrik, there are/were some cases where you get a
surprise AttributeError because a type inconsistency reveals itself
when an object doesn't support a required operation.  This can go
either way: what used to be an AttributeError may become a TypeError,
or vice versa.  (Sorry, no concrete examples right now besides the
previous list(C()) example.)

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