summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-17 14:27:23 +0200
committerGitHub <noreply@github.com>2019-06-17 14:27:23 +0200
commit2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c (patch)
tree85d26a4891196105808df38b430c3332d591da13 /Modules
parent8bf08ee45b7c2341f0d0175b91892843a37c23da (diff)
downloadcpython-git-2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c.tar.gz
bpo-37194: Add a new public PyObject_CallNoArgs() function (GH-13890)
Add a new public PyObject_CallNoArgs() function to the C API: call a callable Python object without any arguments. It is the most efficient way to call a callback without any argument. On x86-64, for example, PyObject_CallFunctionObjArgs(func, NULL) allocates 960 bytes on the stack per call, whereas PyObject_CallNoArgs(func) only allocates 624 bytes per call. It is excluded from stable ABI 3.8. Replace private _PyObject_CallNoArg() with public PyObject_CallNoArgs() in C extensions: _asyncio, _datetime, _elementtree, _pickle, _tkinter and readline.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c12
-rw-r--r--Modules/_datetimemodule.c10
-rw-r--r--Modules/_elementtree.c2
-rw-r--r--Modules/_pickle.c4
-rw-r--r--Modules/_tkinter.c2
-rw-r--r--Modules/readline.c2
6 files changed, 16 insertions, 16 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 281161b686..4caf3a4664 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -216,7 +216,7 @@ get_future_loop(PyObject *fut)
return NULL;
}
if (getloop != NULL) {
- PyObject *res = _PyObject_CallNoArg(getloop);
+ PyObject *res = PyObject_CallNoArgs(getloop);
Py_DECREF(getloop);
return res;
}
@@ -328,7 +328,7 @@ get_event_loop(void)
return loop;
}
- policy = _PyObject_CallNoArg(asyncio_get_event_loop_policy);
+ policy = PyObject_CallNoArgs(asyncio_get_event_loop_policy);
if (policy == NULL) {
return NULL;
}
@@ -510,7 +510,7 @@ future_init(FutureObj *fut, PyObject *loop)
method, which is called during the interpreter shutdown and the
traceback module is already unloaded.
*/
- fut->fut_source_tb = _PyObject_CallNoArg(traceback_extract_stack);
+ fut->fut_source_tb = PyObject_CallNoArgs(traceback_extract_stack);
if (fut->fut_source_tb == NULL) {
return -1;
}
@@ -553,7 +553,7 @@ future_set_exception(FutureObj *fut, PyObject *exc)
}
if (PyExceptionClass_Check(exc)) {
- exc_val = _PyObject_CallNoArg(exc);
+ exc_val = PyObject_CallNoArgs(exc);
if (exc_val == NULL) {
return NULL;
}
@@ -2593,7 +2593,7 @@ task_step_impl(TaskObj *task, PyObject *exc)
if (!exc) {
/* exc was not a CancelledError */
- exc = _PyObject_CallNoArg(asyncio_CancelledError);
+ exc = PyObject_CallNoArgs(asyncio_CancelledError);
if (!exc) {
goto fail;
}
@@ -3308,7 +3308,7 @@ module_init(void)
PyObject *weak_set;
WITH_MOD("weakref")
GET_MOD_ATTR(weak_set, "WeakSet");
- all_tasks = _PyObject_CallNoArg(weak_set);
+ all_tasks = PyObject_CallNoArgs(weak_set);
Py_CLEAR(weak_set);
if (all_tasks == NULL) {
goto fail;
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 4d3562cbe6..2e0211cbbe 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1528,8 +1528,8 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
ntoappend = 1;
}
else if ((ch = *pin++) == '\0') {
- /* Null byte follows %, copy only '%'.
- *
+ /* Null byte follows %, copy only '%'.
+ *
* Back the pin up one char so that we catch the null check
* the next time through the loop.*/
pin--;
@@ -1619,7 +1619,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
usednew += ntoappend;
assert(usednew <= totalnew);
} /* end while() */
-
+
if (_PyBytes_Resize(&newfmt, usednew) < 0)
goto Done;
{
@@ -3607,7 +3607,7 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
getinitargs = _PyObject_GetAttrId(self, &PyId___getinitargs__);
if (getinitargs != NULL) {
- args = _PyObject_CallNoArg(getinitargs);
+ args = PyObject_CallNoArgs(getinitargs);
Py_DECREF(getinitargs);
if (args == NULL) {
return NULL;
@@ -3624,7 +3624,7 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
getstate = _PyObject_GetAttrId(self, &PyId___getstate__);
if (getstate != NULL) {
- state = _PyObject_CallNoArg(getstate);
+ state = PyObject_CallNoArgs(getstate);
Py_DECREF(getstate);
if (state == NULL) {
Py_DECREF(args);
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 8119c8b1e2..ee1b5e5882 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3892,7 +3892,7 @@ _elementtree_XMLParser_close_impl(XMLParserObject *self)
}
else if (self->handle_close) {
Py_DECREF(res);
- return _PyObject_CallNoArg(self->handle_close);
+ return PyObject_CallNoArgs(self->handle_close);
}
else {
return res;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 34e11bd5f8..3adece0f00 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1274,7 +1274,7 @@ _Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)
return -1;
if (n == READ_WHOLE_LINE) {
- data = _PyObject_CallNoArg(self->readline);
+ data = PyObject_CallNoArgs(self->readline);
}
else {
PyObject *len;
@@ -4411,7 +4411,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
/* Check for a __reduce__ method. */
reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
if (reduce_func != NULL) {
- reduce_value = _PyObject_CallNoArg(reduce_func);
+ reduce_value = PyObject_CallNoArgs(reduce_func);
}
else {
PyErr_Format(st->PicklingError,
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 613a95b089..a832099c09 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2768,7 +2768,7 @@ TimerHandler(ClientData clientData)
ENTER_PYTHON
- res = _PyObject_CallNoArg(func);
+ res = PyObject_CallNoArgs(func);
Py_DECREF(func);
Py_DECREF(v); /* See Tktt_New() */
diff --git a/Modules/readline.c b/Modules/readline.c
index 57335fe911..930e63975c 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -867,7 +867,7 @@ on_hook(PyObject *func)
int result = 0;
if (func != NULL) {
PyObject *r;
- r = _PyObject_CallNoArg(func);
+ r = PyObject_CallNoArgs(func);
if (r == NULL)
goto error;
if (r == Py_None)