From 3f6ef1e99f7c517a21d4f53c63b0aeef7e5b5b2c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 1 Dec 2016 14:51:04 +0100 Subject: Replace PyObject_CallFunction() with fastcall Replace PyObject_CallFunction(func, "O", arg) and PyObject_CallFunction(func, "O", arg, NULL) with _PyObject_CallArg1(func, arg) Replace PyObject_CallFunction(func, NULL) with _PyObject_CallNoArg(func) _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. --- Modules/pyexpat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/pyexpat.c') diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index b3259d57aa..541eee7beb 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code) XML_ErrorString(code), lineno, column); if (buffer == NULL) return NULL; - err = PyObject_CallFunction(ErrorObject, "O", buffer); + err = _PyObject_CallArg1(ErrorObject, buffer); Py_DECREF(buffer); if ( err != NULL && set_error_attr(err, "code", code) -- cgit v1.2.1 From 40273ec4f37c65c13a09d0ac23b08c99ebe2f1a3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 5 Dec 2016 17:04:32 +0100 Subject: Issue #28858: Remove _PyObject_CallArg1() macro Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue. --- Modules/pyexpat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/pyexpat.c') diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 541eee7beb..ece4d160eb 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code) XML_ErrorString(code), lineno, column); if (buffer == NULL) return NULL; - err = _PyObject_CallArg1(ErrorObject, buffer); + err = PyObject_CallFunctionObjArgs(ErrorObject, buffer, NULL); Py_DECREF(buffer); if ( err != NULL && set_error_attr(err, "code", code) -- cgit v1.2.1 From bfeec6d871e3db2e0ddfdef01387913bc19cadd4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 23 Jan 2017 09:47:21 +0200 Subject: Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever possible. Patch is writen with Coccinelle. --- Modules/pyexpat.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'Modules/pyexpat.c') diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index ece4d160eb..03bac57272 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -161,8 +161,7 @@ conv_string_to_unicode(const XML_Char *str) and hence in UTF-8. */ /* UTF-8 from Expat, Unicode desired */ if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_DecodeUTF8(str, strlen(str), "strict"); } @@ -174,8 +173,7 @@ conv_string_len_to_unicode(const XML_Char *str, int len) and hence in UTF-8. */ /* UTF-8 from Expat, Unicode desired */ if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_DecodeUTF8((const char *)str, len, "strict"); } @@ -1030,8 +1028,7 @@ pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag) if (rc != XML_ERROR_NONE) { return set_error(self, rc); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif @@ -1322,8 +1319,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) return get_pybool((long) self->specified_attributes); if (_PyUnicode_EqualToASCIIString(nameobj, "intern")) { if (self->intern == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { Py_INCREF(self->intern); -- cgit v1.2.1 From 2da5419cea8ee7c2332331c45ab96b295011bdff Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 4 Feb 2017 11:53:22 +0200 Subject: Removed redundant Argument Clinic directives. --- Modules/pyexpat.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Modules/pyexpat.c') diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 03bac57272..e0c9be732e 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1980,8 +1980,3 @@ static struct HandlerInfo handler_info[] = { {NULL, NULL, NULL} /* sentinel */ }; - -/*[clinic input] -dump buffer -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ -- cgit v1.2.1