On 6/14/06, Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote: > 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 agree. Can you submit a patch to SF please? > 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. Attempting to obtain complete consistency between TypeError and AttributeError is hopeless. But if you want to submit a patch to reduce a particular bit of inconsistency (without increasing it elsewhere) it might well be accepted. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4