bpo-29548: Fix some inefficient call API usage (GH-97)
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 03a4acb..11015df 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3070,7 +3070,7 @@
/* Execute __del__ method, if any. */
del = _PyObject_LookupSpecial(self, &PyId___tp_del__);
if (del != NULL) {
- res = PyEval_CallObject(del, NULL);
+ res = _PyObject_CallNoArg(del);
if (res == NULL)
PyErr_WriteUnraisable(del);
else
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 8be9306..bf25a19 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -994,8 +994,7 @@
_PyThreadState_Init(tstate);
PyEval_AcquireThread(tstate);
nb_threads++;
- res = PyEval_CallObjectWithKeywords(
- boot->func, boot->args, boot->keyw);
+ res = PyObject_Call(boot->func, boot->args, boot->keyw);
if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
PyErr_Clear();
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index f69a4df..1abc0e2 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2417,7 +2417,7 @@
}
PyTuple_SET_ITEM(arg, i, s);
}
- res = PyEval_CallObject(func, arg);
+ res = PyObject_Call(func, arg, NULL);
Py_DECREF(arg);
if (res == NULL)
@@ -2661,16 +2661,13 @@
FileHandler(ClientData clientData, int mask)
{
FileHandler_ClientData *data = (FileHandler_ClientData *)clientData;
- PyObject *func, *file, *arg, *res;
+ PyObject *func, *file, *res;
ENTER_PYTHON
func = data->func;
file = data->file;
- arg = Py_BuildValue("(Oi)", file, (long) mask);
- res = PyEval_CallObject(func, arg);
- Py_DECREF(arg);
-
+ res = PyObject_CallFunction(func, "Oi", file, mask);
if (res == NULL) {
errorInCmd = 1;
PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd);
@@ -2840,7 +2837,7 @@
ENTER_PYTHON
- res = PyEval_CallObject(func, NULL);
+ res = _PyObject_CallNoArg(func);
Py_DECREF(func);
Py_DECREF(v); /* See Tktt_New() */