Author belopolsky
Recipients
Date 2006-06-15.16:24:45
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When an extension type Foo defines tp_getattr, but
leaves tp_setattr NULL, an attempt to set an attribute
bar results in an AttributeError with the message
"'Foo' object has no attribute 'bar'".  This message is
misleading because the object may have the attribute
'bar' as implemented in tp_getattr.  It would be better
to change the message to "'Foo' object has only
read-only attributes (assign to .bar)" as in the case
tp_setattro == tp_setattr == NULL in  PyObject_SetAttr .

I've also noticed that the exceptions raised from
PyObject_SetAttr are TypeErrors. Shouldn't
PyObject_GenericSetAttr raise a TypeError if tp_setattr
is null but tp_getattr is not?  This would be
consistent with the errors from read-only descriptors.
History
Date User Action Args
2007-08-23 14:40:36adminlinkissue1506776 messages
2007-08-23 14:40:36admincreate