There was an error while loading. Please reload this page.
1 parent d09c134 commit 635bfe8Copy full SHA for 635bfe8
2 files changed
Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst
@@ -0,0 +1,2 @@
1
+Update ``property_descr_set`` to use vectorcall if possible. Patch by Dong-hee
2
+Na.
Objects/descrobject.c
@@ -1614,31 +1614,42 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
1614
propertyobject *gs = (propertyobject *)self;
1615
PyObject *func, *res;
1616
1617
- if (value == NULL)
+ if (value == NULL) {
1618
func = gs->prop_del;
1619
- else
+ }
1620
+ else {
1621
func = gs->prop_set;
1622
1623
+
1624
if (func == NULL) {
1625
if (gs->prop_name != NULL) {
1626
PyErr_Format(PyExc_AttributeError,
1627
value == NULL ?
1628
"can't delete attribute %R" :
1629
"can't set attribute %R",
1630
gs->prop_name);
- } else {
1631
1632
1633
PyErr_SetString(PyExc_AttributeError,
1634
1635
"can't delete attribute" :
1636
"can't set attribute");
1637
}
1638
return -1;
1639
1640
1641
1642
res = PyObject_CallOneArg(func, obj);
- res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
- if (res == NULL)
1643
1644
1645
+ PyObject *args[] = { obj, value };
1646
+ res = PyObject_Vectorcall(func, args, 2, NULL);
1647
1648
1649
+ if (res == NULL) {
1650
1651
1652
1653
Py_DECREF(res);
1654
return 0;
1655
0 commit comments