Skip to content

Commit 635bfe8

Browse files
authored
bpo-44661: Update property_descr_set to use vectorcall if possible. (GH-27206)
1 parent d09c134 commit 635bfe8

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update ``property_descr_set`` to use vectorcall if possible. Patch by Dong-hee
2+
Na.

Objects/descrobject.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,31 +1614,42 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
16141614
propertyobject *gs = (propertyobject *)self;
16151615
PyObject *func, *res;
16161616

1617-
if (value == NULL)
1617+
if (value == NULL) {
16181618
func = gs->prop_del;
1619-
else
1619+
}
1620+
else {
16201621
func = gs->prop_set;
1622+
}
1623+
16211624
if (func == NULL) {
16221625
if (gs->prop_name != NULL) {
16231626
PyErr_Format(PyExc_AttributeError,
16241627
value == NULL ?
16251628
"can't delete attribute %R" :
16261629
"can't set attribute %R",
16271630
gs->prop_name);
1628-
} else {
1631+
}
1632+
else {
16291633
PyErr_SetString(PyExc_AttributeError,
16301634
value == NULL ?
16311635
"can't delete attribute" :
16321636
"can't set attribute");
16331637
}
16341638
return -1;
16351639
}
1636-
if (value == NULL)
1640+
1641+
if (value == NULL) {
16371642
res = PyObject_CallOneArg(func, obj);
1638-
else
1639-
res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
1640-
if (res == NULL)
1643+
}
1644+
else {
1645+
PyObject *args[] = { obj, value };
1646+
res = PyObject_Vectorcall(func, args, 2, NULL);
1647+
}
1648+
1649+
if (res == NULL) {
16411650
return -1;
1651+
}
1652+
16421653
Py_DECREF(res);
16431654
return 0;
16441655
}

0 commit comments

Comments
 (0)