bpo-29548: Fix some inefficient call API usage (GH-97)

This commit is contained in:
INADA Naoki 2017-02-16 09:26:01 +09:00 committed by GitHub
parent 72e81d00ee
commit 72dccde884
7 changed files with 23 additions and 40 deletions

View file

@ -3070,7 +3070,7 @@ slot_tp_del(PyObject *self)
/* 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

View file

@ -994,8 +994,7 @@ t_bootstrap(void *boot_raw)
_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();

View file

@ -2417,7 +2417,7 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[
}
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 @@ static void
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 @@ TimerHandler(ClientData clientData)
ENTER_PYTHON
res = PyEval_CallObject(func, NULL);
res = _PyObject_CallNoArg(func);
Py_DECREF(func);
Py_DECREF(v); /* See Tktt_New() */