From a4595662f4654d2f013023045797f075b56fc1b1 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 17 Jul 2021 14:12:24 +0900 Subject: [PATCH 1/3] bpo-44661: Update property_descr_set to use vectorcall if possible. --- .../2021-07-17-14-20-59.bpo-44661.BQbXiH.rst | 2 ++ Objects/descrobject.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst b/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst new file mode 100644 index 00000000000000..780e4aa940b496 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst @@ -0,0 +1,2 @@ +Update property_descr_set to use vectorcall if possible. Patch by Dong-hee +Na. diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 57a9607d10c31a..ce24d7aa1e674c 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1633,10 +1633,12 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) } return -1; } - if (value == NULL) + if (value == NULL) { res = PyObject_CallOneArg(func, obj); - else - res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); + } else { + PyObject *args[] = { obj, value }; + res = PyObject_Vectorcall(func, args, 2, NULL); + } if (res == NULL) return -1; Py_DECREF(res); From 0b73f89d05e81b51d5f3575a9f989383e1a36e2c Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 17 Jul 2021 15:13:48 +0900 Subject: [PATCH 2/3] bpo-44661: Follow PEP7 --- Objects/descrobject.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index ce24d7aa1e674c..0565992bdb79f7 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1614,10 +1614,13 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) propertyobject *gs = (propertyobject *)self; PyObject *func, *res; - if (value == NULL) + if (value == NULL) { func = gs->prop_del; - else + } + else { func = gs->prop_set; + } + if (func == NULL) { if (gs->prop_name != NULL) { PyErr_Format(PyExc_AttributeError, @@ -1625,7 +1628,8 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) "can't delete attribute %R" : "can't set attribute %R", gs->prop_name); - } else { + } + else { PyErr_SetString(PyExc_AttributeError, value == NULL ? "can't delete attribute" : @@ -1633,14 +1637,19 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) } return -1; } + if (value == NULL) { res = PyObject_CallOneArg(func, obj); - } else { + } + else { PyObject *args[] = { obj, value }; res = PyObject_Vectorcall(func, args, 2, NULL); } - if (res == NULL) + + if (res == NULL) { return -1; + } + Py_DECREF(res); return 0; } From 5b615482f60629065dd115d441aaf1fdc266508e Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 17 Jul 2021 17:39:31 +0900 Subject: [PATCH 3/3] bpo-44661: Update NEWS.d --- .../Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst b/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst index 780e4aa940b496..bafa98e5826cd4 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2021-07-17-14-20-59.bpo-44661.BQbXiH.rst @@ -1,2 +1,2 @@ -Update property_descr_set to use vectorcall if possible. Patch by Dong-hee +Update ``property_descr_set`` to use vectorcall if possible. Patch by Dong-hee Na. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy