summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-21 12:55:49 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-21 12:55:49 (GMT)
commitcf4fb40b9d68939d9cf5345a06547b2200e36b31 (patch)
treee20d88755b01f402c1ea30b47b6d4e42ec84ce1d /Objects
parentd55bdb86caf53b8219c0c2d5704fce844ad39782 (diff)
parentafd02a439f864c8380a8554ae6cb9726b996fd5e (diff)
downloadcpython-cf4fb40b9d68939d9cf5345a06547b2200e36b31.zip
cpython-cf4fb40b9d68939d9cf5345a06547b2200e36b31.tar.gz
cpython-cf4fb40b9d68939d9cf5345a06547b2200e36b31.tar.bz2
Issue #28214: Now __set_name__ is looked up on the class instead of the
instance.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 5028304..e799a57 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -6990,19 +6990,21 @@ update_all_slots(PyTypeObject* type)
static int
set_names(PyTypeObject *type)
{
- PyObject *key, *value, *tmp;
+ PyObject *key, *value, *set_name, *tmp;
Py_ssize_t i = 0;
while (PyDict_Next(type->tp_dict, &i, &key, &value)) {
- if (PyObject_HasAttr(value, _PyUnicode_FromId(&PyId___set_name__))) {
- tmp = PyObject_CallMethodObjArgs(
- value, _PyUnicode_FromId(&PyId___set_name__),
- type, key, NULL);
+ set_name = lookup_maybe(value, &PyId___set_name__);
+ if (set_name != NULL) {
+ tmp = PyObject_CallFunctionObjArgs(set_name, type, key, NULL);
+ Py_DECREF(set_name);
if (tmp == NULL)
return -1;
else
Py_DECREF(tmp);
}
+ else if (PyErr_Occurred())
+ return -1;
}
return 0;