[Python-Dev] __getattribute__ should require a string?

Guido van Rossum guido@python.org
Tue, 04 Dec 2001 10:32:27 -0500

> > Is there any reason why people should be allowed to assign and
> >  retrieve attributes with non-string names?
> Not really, but why should we actively try to prevent it when it's
> easy to do self.__dict__[1] = 'a'?  This means you can't rely on all
> attribute names being strings, and I'm not going to prevent *that*.
> The proper fix IMO for the bug you found is to be more careful when
> formatting the error message.

I take it back.  All the other functions in object.c require the
getattr/setattr argument to be a string or Unicode object.  I'll fix
object.__getattribute__ and object.__setattr__ (which are really
PyObject_Generic{Get,Set}Attr) to do the same.

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