mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
As per discussion on python-dev, descriptors defined in C with a NULL setter
now raise AttributeError instead of TypeError, for consistency with their pure-Python equivalent.
This commit is contained in:
parent
a267563f43
commit
c8d907c60b
2 changed files with 7 additions and 2 deletions
|
@ -144,7 +144,7 @@ getset_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type)
|
|||
return res;
|
||||
if (descr->d_getset->get != NULL)
|
||||
return descr->d_getset->get(obj, descr->d_getset->closure);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"attribute '%.300s' of '%.100s' objects is not readable",
|
||||
descr_name((PyDescrObject *)descr),
|
||||
descr->d_type->tp_name);
|
||||
|
@ -199,7 +199,7 @@ getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
|
|||
if (descr->d_getset->set != NULL)
|
||||
return descr->d_getset->set(obj, value,
|
||||
descr->d_getset->closure);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"attribute '%.300s' of '%.100s' objects is not writable",
|
||||
descr_name((PyDescrObject *)descr),
|
||||
descr->d_type->tp_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue