[Python-Dev] 2.2=>2.3 object.__setattr__(cls,attr,value)
Jeremy Hylton
jeremy at alum.mit.edu
Tue Nov 18 23:07:22 EST 2003
On Tue, 2003-11-18 at 22:23, David Eppstein wrote:
> In 2.2 I was able to call object.__setattr__(cls,attr,value)
> where cls is a new-style type (first argument of a classmethod),
> and attr and value are the name and value of a class attribute I want to
> create programmatically. I just upgraded to 2.3 but now when I try it I
> get
>
> >>> class foo(object):pass
> ...
> >>> object.__setattr__(foo,'foo',None)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: can't apply this __setattr__ to type object
>
> Instead I apparently have to call
> >>> type(foo).__setattr__(foo,'foo',None)
>
>
> Anyway, my question: no harm done here because this was in undeployed
> code and I've found a workaround, but shouldn't this have at least been
> mentioned in "What's New in Python 2.3"? Or maybe this is one of the
> some-other-change-with-far-reaching-consequences things that was
> mentioned and I just don't see the connection?
The change was reported on python-dev, but apparently got left out of
the NEWS file. Here are the details:
http://mail.python.org/pipermail/python-dev/2003-April/034605.html
I don't know that it does much good to change NEWS after the fact, but I
don't think there's anything more that can be done.
Jeremy
More information about the Python-Dev
mailing list