◐ Shell
clean mode source ↗

bpo-29548: Fix some inefficient call API usage by methane · Pull Request #97 · python/cpython

Expand Up @@ -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) Expand Down Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg variable is no more used and can be removed, no?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I missed it.
Additionally, argument for "i" format should be int, not (long).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, argument for "i" format should be int, not (long).

Right, I spotted it as well, but then I forgot to report it, sorry :-) Hopefully you fixed it!

if (res == NULL) { errorInCmd = 1; PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); Expand Down Expand Up @@ -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() */
Expand Down