[Python-checkins] cpython: Issue #28858: Remove _PyObject_CallArg1() macro

victor.stinner python-checkins at python.org
Mon Dec 5 11:13:08 EST 2016


https://hg.python.org/cpython/rev/4171cc26272c
changeset: 105461:4171cc26272c
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Dec 05 17:04:32 2016 +0100
summary:
 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.
files:
 Include/abstract.h | 5 +----
 Modules/_asynciomodule.c | 6 +++---
 Modules/_collectionsmodule.c | 3 ++-
 Modules/_elementtree.c | 11 ++++++-----
 Modules/_pickle.c | 2 +-
 Modules/_sre.c | 2 +-
 Modules/pyexpat.c | 2 +-
 Objects/abstract.c | 2 +-
 Objects/fileobject.c | 2 +-
 Objects/genobject.c | 2 +-
 Objects/typeobject.c | 6 +++---
 Python/_warnings.c | 2 +-
 Python/codecs.c | 2 +-
 Python/errors.c | 2 +-
 Python/sysmodule.c | 2 +-
 15 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/Include/abstract.h b/Include/abstract.h
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -338,10 +338,7 @@
 _PyObject_FastCallDict((func), (args), (nargs), NULL)
 
 #define _PyObject_CallNoArg(func) \
- _PyObject_FastCall((func), NULL, 0)
-
-#define _PyObject_CallArg1(func, arg) \
- _PyObject_FastCall((func), (PyObject **)&(arg), 1)
+ _PyObject_FastCallDict((func), NULL, 0, NULL)
 
 PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(PyObject *func,
 PyObject *obj, PyObject *args,
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -257,7 +257,7 @@
 return -1;
 }
 
- exc = _PyObject_CallArg1(asyncio_InvalidStateError, msg);
+ exc = PyObject_CallFunctionObjArgs(asyncio_InvalidStateError, msg, NULL);
 Py_DECREF(msg);
 if (exc == NULL) {
 return -1;
@@ -835,7 +835,7 @@
 
 func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler);
 if (func != NULL) {
- res = _PyObject_CallArg1(func, context);
+ res = PyObject_CallFunctionObjArgs(func, context, NULL);
 if (res == NULL) {
 PyErr_WriteUnraisable(func);
 }
@@ -1731,7 +1731,7 @@
 
 func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler);
 if (func != NULL) {
- res = _PyObject_CallArg1(func, context);
+ res = PyObject_CallFunctionObjArgs(func, context, NULL);
 if (res == NULL) {
 PyErr_WriteUnraisable(func);
 }
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -538,7 +538,8 @@
 return NULL;
 }
 if (old_deque->maxlen < 0)
- return _PyObject_CallArg1((PyObject *)(Py_TYPE(deque)), deque);
+ return PyObject_CallFunctionObjArgs((PyObject *)(Py_TYPE(deque)),
+ deque, NULL);
 else
 return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
 deque, old_deque->maxlen, NULL);
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2831,7 +2831,7 @@
 if (errmsg == NULL)
 return;
 
- error = _PyObject_CallArg1(st->parseerror_obj, errmsg);
+ error = PyObject_CallFunctionObjArgs(st->parseerror_obj, errmsg, NULL);
 Py_DECREF(errmsg);
 if (!error)
 return;
@@ -2894,7 +2894,7 @@
 (TreeBuilderObject*) self->target, value
 );
 else if (self->handle_data)
- res = _PyObject_CallArg1(self->handle_data, value);
+ res = PyObject_CallFunctionObjArgs(self->handle_data, value, NULL);
 else
 res = NULL;
 Py_XDECREF(res);
@@ -3004,7 +3004,7 @@
 /* shortcut */
 res = treebuilder_handle_data((TreeBuilderObject*) self->target, data);
 else if (self->handle_data)
- res = _PyObject_CallArg1(self->handle_data, data);
+ res = PyObject_CallFunctionObjArgs(self->handle_data, data, NULL);
 else
 res = NULL;
 
@@ -3031,7 +3031,7 @@
 else if (self->handle_end) {
 tag = makeuniversal(self, tag_in);
 if (tag) {
- res = _PyObject_CallArg1(self->handle_end, tag);
+ res = PyObject_CallFunctionObjArgs(self->handle_end, tag, NULL);
 Py_DECREF(tag);
 }
 }
@@ -3090,7 +3090,8 @@
 if (self->handle_comment) {
 comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), "strict");
 if (comment) {
- res = _PyObject_CallArg1(self->handle_comment, comment);
+ res = PyObject_CallFunctionObjArgs(self->handle_comment,
+ comment, NULL);
 Py_XDECREF(res);
 Py_DECREF(comment);
 }
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -346,7 +346,7 @@
 {
 PyObject *result;
 
- result = _PyObject_CallArg1(func, obj);
+ result = PyObject_CallFunctionObjArgs(func, obj, NULL);
 Py_DECREF(obj);
 return result;
 }
diff --git a/Modules/_sre.c b/Modules/_sre.c
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1157,7 +1157,7 @@
 match = pattern_new_match(self, &state, 1);
 if (!match)
 goto error;
- item = _PyObject_CallArg1(filter, match);
+ item = PyObject_CallFunctionObjArgs(filter, match, NULL);
 Py_DECREF(match);
 if (!item)
 goto error;
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -119,7 +119,7 @@
 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)
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2496,7 +2496,7 @@
 assert(args != NULL);
 
 if (!PyTuple_Check(args)) {
- result = _PyObject_CallArg1(callable, args);
+ result = PyObject_CallFunctionObjArgs(callable, args, NULL);
 }
 else {
 result = PyObject_Call(callable, args, NULL);
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -146,7 +146,7 @@
 Py_DECREF(writer);
 return -1;
 }
- result = _PyObject_CallArg1(writer, value);
+ result = PyObject_CallFunctionObjArgs(writer, value, NULL);
 Py_DECREF(value);
 Py_DECREF(writer);
 if (result == NULL)
diff --git a/Objects/genobject.c b/Objects/genobject.c
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -1341,7 +1341,7 @@
 PyObject *res;
 
 Py_INCREF(firstiter);
- res = _PyObject_CallArg1(firstiter, o);
+ res = PyObject_CallFunctionObjArgs(firstiter, o, NULL);
 Py_DECREF(firstiter);
 if (res == NULL) {
 return 1;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5873,7 +5873,7 @@
 goto error;
 }
 
- retval = _PyObject_CallArg1(func, ival);
+ retval = PyObject_CallFunctionObjArgs(func, ival, NULL);
 Py_DECREF(func);
 Py_DECREF(ival);
 return retval;
@@ -5914,7 +5914,7 @@
 return -1;
 }
 if (func != NULL) {
- res = _PyObject_CallArg1(func, value);
+ res = PyObject_CallFunctionObjArgs(func, value, NULL);
 Py_DECREF(func);
 if (res != NULL) {
 result = PyObject_IsTrue(res);
@@ -6284,7 +6284,7 @@
 PyErr_Clear();
 Py_RETURN_NOTIMPLEMENTED;
 }
- res = _PyObject_CallArg1(func, other);
+ res = PyObject_CallFunctionObjArgs(func, other, NULL);
 Py_DECREF(func);
 return res;
 }
diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -476,7 +476,7 @@
 }
 else {
 text = message;
- message = _PyObject_CallArg1(category, message);
+ message = PyObject_CallFunctionObjArgs(category, message, NULL);
 if (message == NULL)
 goto cleanup;
 }
diff --git a/Python/codecs.c b/Python/codecs.c
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -322,7 +322,7 @@
 if (errors != NULL)
 streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
 else
- streamcodec = _PyObject_CallArg1(codeccls, stream);
+ streamcodec = PyObject_CallFunctionObjArgs(codeccls, stream, NULL);
 Py_DECREF(codecs);
 return streamcodec;
 }
diff --git a/Python/errors.c b/Python/errors.c
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -62,7 +62,7 @@
 return PyObject_Call(exception, value, NULL);
 }
 else {
- return _PyObject_CallArg1(exception, value);
+ return PyObject_CallFunctionObjArgs(exception, value, NULL);
 }
 }
 
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2325,7 +2325,7 @@
 if (writer == NULL)
 goto error;
 
- result = _PyObject_CallArg1(writer, unicode);
+ result = PyObject_CallFunctionObjArgs(writer, unicode, NULL);
 if (result == NULL) {
 goto error;
 } else {
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /