[issue7659] Attribute assignment on object() instances raises wrong exception
Brian Curtin
report at bugs.python.org
Fri Jan 8 18:29:58 CET 2010
Brian Curtin <curtin at acm.org> added the comment:
The 3.x documentation[1] has this:
"object does not have a __dict__, so you can’t assign arbitrary attributes to an instance of the object class."
- 2.x doesn't have that same blurb -- it looks like it should.
AttributeError vs. TypeError seems to be the issue here.
FWIW, the way to achieve what you had in your example is something like this:
>>> a = type("my_type", (object,), {})
>>> a.abc = 3
[1] http://docs.python.org/3.1/library/functions.html#object
----------
nosy: +brian.curtin
stage: -> needs patch
title: Problems with attribute assignment on object instances -> Attribute assignment on object() instances raises wrong exception
versions: +Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7659>
_______________________________________
More information about the Python-bugs-list
mailing list