[New-bugs-announce] [issue7659] Problems with attribute assignment on object instances

Pascal Chambon report at bugs.python.org
Fri Jan 8 17:32:12 CET 2010

New submission from Pascal Chambon <chambon.pascal at gmail.com>:

It seems we can't assign attributes to "objet" class instances, which don't have a __dict__ :

IDLE 2.6.4      
>>> a = object()
>>> a.abc = 3

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    a.abc = 3
AttributeError: 'object' object has no attribute 'abc'

This behaviour seems undocumented, and contradicts the documentation on AttributeError -> normally, a TypeError should be raised instead:

exception AttributeError
    Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)

components: Interpreter Core
messages: 97416
nosy: pakal
severity: normal
status: open
title: Problems with attribute assignment on object instances
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list