Bugs item #1506776, was opened at 2006-06-15 12:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1506776&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Belopolsky (belopolsky)
Assigned to: Nobody/Anonymous (nobody)
Summary: Misleading error message from PyObject_GenericSetAttr  

Initial Comment:
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.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1506776&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to