Use _PyObject_CallNoArg()

Replace:
    PyObject_CallFunctionObjArgs(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
This commit is contained in:
Victor Stinner 2016-12-06 18:46:19 +01:00
parent a5ed5f000a
commit f17c3de263
15 changed files with 21 additions and 21 deletions

View File

@ -1948,7 +1948,7 @@ task_step_impl(TaskObj *task, PyObject *exc)
if (!exc) { if (!exc) {
/* exc was not a CancelledError */ /* exc was not a CancelledError */
exc = PyObject_CallFunctionObjArgs(asyncio_CancelledError, NULL); exc = _PyObject_CallNoArg(asyncio_CancelledError);
if (!exc) { if (!exc) {
goto fail; goto fail;
} }

View File

@ -5258,7 +5258,7 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
CDataObject *result; CDataObject *result;
if (0 == cast_check_pointertype(ctype)) if (0 == cast_check_pointertype(ctype))
return NULL; return NULL;
result = (CDataObject *)PyObject_CallFunctionObjArgs(ctype, NULL); result = (CDataObject *)_PyObject_CallNoArg(ctype);
if (result == NULL) if (result == NULL)
return NULL; return NULL;

View File

@ -181,7 +181,7 @@ static void _CallPythonObject(void *mem,
*/ */
} else if (dict) { } else if (dict) {
/* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */ /* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */
CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL); CDataObject *obj = (CDataObject *)_PyObject_CallNoArg(cnv);
if (!obj) { if (!obj) {
PrintError("create argument %d:\n", i); PrintError("create argument %d:\n", i);
Py_DECREF(cnv); Py_DECREF(cnv);

View File

@ -3197,7 +3197,7 @@ _password_callback(char *buf, int size, int rwflag, void *userdata)
PySSL_END_ALLOW_THREADS_S(pw_info->thread_state); PySSL_END_ALLOW_THREADS_S(pw_info->thread_state);
if (pw_info->callable) { if (pw_info->callable) {
fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL); fn_ret = _PyObject_CallNoArg(pw_info->callable);
if (!fn_ret) { if (!fn_ret) {
/* TODO: It would be nice to move _ctypes_add_traceback() into the /* TODO: It would be nice to move _ctypes_add_traceback() into the
core python API, so we could use it to add a frame here */ core python API, so we could use it to add a frame here */

View File

@ -951,7 +951,7 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) {
return NULL; return NULL;
return math_1_to_int(number, ceil, 0); return math_1_to_int(number, ceil, 0);
} }
result = PyObject_CallFunctionObjArgs(method, NULL); result = _PyObject_CallNoArg(method);
Py_DECREF(method); Py_DECREF(method);
return result; return result;
} }
@ -991,7 +991,7 @@ static PyObject * math_floor(PyObject *self, PyObject *number) {
return NULL; return NULL;
return math_1_to_int(number, floor, 0); return math_1_to_int(number, floor, 0);
} }
result = PyObject_CallFunctionObjArgs(method, NULL); result = _PyObject_CallNoArg(method);
Py_DECREF(method); Py_DECREF(method);
return result; return result;
} }
@ -1542,7 +1542,7 @@ math_trunc(PyObject *self, PyObject *number)
Py_TYPE(number)->tp_name); Py_TYPE(number)->tp_name);
return NULL; return NULL;
} }
result = PyObject_CallFunctionObjArgs(trunc, NULL); result = _PyObject_CallNoArg(trunc);
Py_DECREF(trunc); Py_DECREF(trunc);
return result; return result;
} }

View File

@ -902,7 +902,7 @@ path_converter(PyObject *o, void *p)
goto error_exit; goto error_exit;
} }
o = to_cleanup = PyObject_CallFunctionObjArgs(func, NULL); o = to_cleanup = _PyObject_CallNoArg(func);
Py_DECREF(func); Py_DECREF(func);
if (NULL == o) { if (NULL == o) {
goto error_exit; goto error_exit;
@ -12046,7 +12046,7 @@ PyOS_FSPath(PyObject *path)
Py_TYPE(path)->tp_name); Py_TYPE(path)->tp_name);
} }
path_repr = PyObject_CallFunctionObjArgs(func, NULL); path_repr = _PyObject_CallNoArg(func);
Py_DECREF(func); Py_DECREF(func);
if (NULL == path_repr) { if (NULL == path_repr) {
return NULL; return NULL;

View File

@ -103,7 +103,7 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
} }
return defaultvalue; return defaultvalue;
} }
result = PyObject_CallFunctionObjArgs(hint, NULL); result = _PyObject_CallNoArg(hint);
Py_DECREF(hint); Py_DECREF(hint);
if (result == NULL) { if (result == NULL) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) { if (PyErr_ExceptionMatches(PyExc_TypeError)) {

View File

@ -549,7 +549,7 @@ format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
/* does it support __bytes__? */ /* does it support __bytes__? */
func = _PyObject_LookupSpecial(v, &PyId___bytes__); func = _PyObject_LookupSpecial(v, &PyId___bytes__);
if (func != NULL) { if (func != NULL) {
result = PyObject_CallFunctionObjArgs(func, NULL); result = _PyObject_CallNoArg(func);
Py_DECREF(func); Py_DECREF(func);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
@ -2569,7 +2569,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_Bytes doesn't do. */ PyObject_Bytes doesn't do. */
func = _PyObject_LookupSpecial(x, &PyId___bytes__); func = _PyObject_LookupSpecial(x, &PyId___bytes__);
if (func != NULL) { if (func != NULL) {
new = PyObject_CallFunctionObjArgs(func, NULL); new = _PyObject_CallNoArg(func);
Py_DECREF(func); Py_DECREF(func);
if (new == NULL) if (new == NULL)
return NULL; return NULL;

View File

@ -273,7 +273,7 @@ try_complex_special_method(PyObject *op) {
f = _PyObject_LookupSpecial(op, &PyId___complex__); f = _PyObject_LookupSpecial(op, &PyId___complex__);
if (f) { if (f) {
PyObject *res = PyObject_CallFunctionObjArgs(f, NULL); PyObject *res = _PyObject_CallNoArg(f);
Py_DECREF(f); Py_DECREF(f);
if (res != NULL && !PyComplex_Check(res)) { if (res != NULL && !PyComplex_Check(res)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,

View File

@ -258,7 +258,7 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL; return NULL;
} }
if (reversed_meth != NULL) { if (reversed_meth != NULL) {
PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL); PyObject *res = _PyObject_CallNoArg(reversed_meth);
Py_DECREF(reversed_meth); Py_DECREF(reversed_meth);
return res; return res;
} }

View File

@ -596,7 +596,7 @@ PyObject_Bytes(PyObject *v)
func = _PyObject_LookupSpecial(v, &PyId___bytes__); func = _PyObject_LookupSpecial(v, &PyId___bytes__);
if (func != NULL) { if (func != NULL) {
result = PyObject_CallFunctionObjArgs(func, NULL); result = _PyObject_CallNoArg(func);
Py_DECREF(func); Py_DECREF(func);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
@ -1314,7 +1314,7 @@ _dir_object(PyObject *obj)
return NULL; return NULL;
} }
/* use __dir__ */ /* use __dir__ */
result = PyObject_CallFunctionObjArgs(dirfunc, NULL); result = _PyObject_CallNoArg(dirfunc);
Py_DECREF(dirfunc); Py_DECREF(dirfunc);
if (result == NULL) if (result == NULL)
return NULL; return NULL;

View File

@ -1256,7 +1256,7 @@ odict_copy(register PyODictObject *od)
if (PyODict_CheckExact(od)) if (PyODict_CheckExact(od))
od_copy = PyODict_New(); od_copy = PyODict_New();
else else
od_copy = PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(od), NULL); od_copy = _PyObject_CallNoArg((PyObject *)Py_TYPE(od));
if (od_copy == NULL) if (od_copy == NULL)
return NULL; return NULL;

View File

@ -2074,7 +2074,7 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
} }
if (ndigits == NULL || ndigits == Py_None) if (ndigits == NULL || ndigits == Py_None)
result = PyObject_CallFunctionObjArgs(round, NULL); result = _PyObject_CallNoArg(round);
else else
result = PyObject_CallFunctionObjArgs(round, ndigits, NULL); result = PyObject_CallFunctionObjArgs(round, ndigits, NULL);
Py_DECREF(round); Py_DECREF(round);

View File

@ -3062,7 +3062,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
Py_DECREF(mgr); Py_DECREF(mgr);
if (enter == NULL) if (enter == NULL)
goto error; goto error;
res = PyObject_CallFunctionObjArgs(enter, NULL); res = _PyObject_CallNoArg(enter);
Py_DECREF(enter); Py_DECREF(enter);
if (res == NULL) if (res == NULL)
goto error; goto error;
@ -3096,7 +3096,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
} }
SET_TOP(exit); SET_TOP(exit);
Py_DECREF(mgr); Py_DECREF(mgr);
res = PyObject_CallFunctionObjArgs(enter, NULL); res = _PyObject_CallNoArg(enter);
Py_DECREF(enter); Py_DECREF(enter);
if (res == NULL) if (res == NULL)
goto error; goto error;

View File

@ -1098,7 +1098,7 @@ _PySys_GetSizeOf(PyObject *o)
Py_TYPE(o)->tp_name); Py_TYPE(o)->tp_name);
} }
else { else {
res = PyObject_CallFunctionObjArgs(method, NULL); res = _PyObject_CallNoArg(method);
Py_DECREF(method); Py_DECREF(method);
} }