bpo-37483: add _PyObject_CallOneArg() function (#14558)

This commit is contained in:
Jeroen Demeyer 2019-07-04 12:31:34 +02:00 committed by Inada Naoki
parent 9d40554e0d
commit 196a530e00
44 changed files with 128 additions and 146 deletions

View file

@ -590,7 +590,7 @@ call_show_warning(PyObject *category, PyObject *text, PyObject *message,
if (msg == NULL)
goto error;
res = PyObject_CallFunctionObjArgs(show_fn, msg, NULL);
res = _PyObject_CallOneArg(show_fn, msg);
Py_DECREF(show_fn);
Py_DECREF(msg);
@ -651,7 +651,7 @@ warn_explicit(PyObject *category, PyObject *message,
}
else {
text = message;
message = PyObject_CallFunctionObjArgs(category, message, NULL);
message = _PyObject_CallOneArg(category, message);
if (message == NULL)
goto cleanup;
}
@ -996,7 +996,7 @@ get_source_line(PyObject *module_globals, int lineno)
return NULL;
}
/* Call get_source() to get the source code. */
source = PyObject_CallFunctionObjArgs(get_source, module_name, NULL);
source = _PyObject_CallOneArg(get_source, module_name);
Py_DECREF(get_source);
Py_DECREF(module_name);
if (!source) {
@ -1283,7 +1283,7 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
int warned = 0;
PyObject *fn = get_warnings_attr(&PyId__warn_unawaited_coroutine, 1);
if (fn) {
PyObject *res = PyObject_CallFunctionObjArgs(fn, coro, NULL);
PyObject *res = _PyObject_CallOneArg(fn, coro);
Py_DECREF(fn);
if (res || PyErr_ExceptionMatches(PyExc_RuntimeWarning)) {
warned = 1;

View file

@ -29,7 +29,6 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs)
{
Py_ssize_t i, j;
PyObject *base, *meth, *new_base, *result, *new_bases = NULL;
PyObject *stack[1] = {bases};
assert(PyTuple_Check(bases));
for (i = 0; i < nargs; i++) {
@ -55,7 +54,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs)
}
continue;
}
new_base = _PyObject_FastCall(meth, stack, 1);
new_base = _PyObject_CallOneArg(meth, bases);
Py_DECREF(meth);
if (!new_base) {
goto error;
@ -574,7 +573,7 @@ filter_next(filterobject *lz)
ok = PyObject_IsTrue(item);
} else {
PyObject *good;
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
good = _PyObject_CallOneArg(lz->func, item);
if (good == NULL) {
Py_DECREF(item);
return NULL;
@ -1625,7 +1624,7 @@ min_max(PyObject *args, PyObject *kwds, int op)
while (( item = PyIter_Next(it) )) {
/* get the value from the key function */
if (keyfunc != NULL) {
val = PyObject_CallFunctionObjArgs(keyfunc, item, NULL);
val = _PyObject_CallOneArg(keyfunc, item);
if (val == NULL)
goto Fail_it_item;
}
@ -2178,7 +2177,7 @@ builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits)
if (ndigits == NULL || ndigits == Py_None)
result = _PyObject_CallNoArg(round);
else
result = PyObject_CallFunctionObjArgs(round, ndigits, NULL);
result = _PyObject_CallOneArg(round, ndigits);
Py_DECREF(round);
return result;
}

View file

@ -1874,7 +1874,7 @@ main_loop:
Py_DECREF(value);
goto error;
}
res = PyObject_CallFunctionObjArgs(hook, value, NULL);
res = _PyObject_CallOneArg(hook, value);
Py_DECREF(value);
if (res == NULL)
goto error;

View file

@ -99,7 +99,7 @@ PyObject *normalizestring(const char *string)
PyObject *_PyCodec_Lookup(const char *encoding)
{
PyObject *result, *args = NULL, *v;
PyObject *result, *v;
Py_ssize_t i, len;
if (encoding == NULL) {
@ -132,13 +132,6 @@ PyObject *_PyCodec_Lookup(const char *encoding)
}
/* Next, scan the search functions in order of registration */
args = PyTuple_New(1);
if (args == NULL) {
Py_DECREF(v);
return NULL;
}
PyTuple_SET_ITEM(args,0,v);
len = PyList_Size(interp->codec_search_path);
if (len < 0)
goto onError;
@ -155,7 +148,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
func = PyList_GetItem(interp->codec_search_path, i);
if (func == NULL)
goto onError;
result = PyEval_CallObject(func, args);
result = _PyObject_CallOneArg(func, v);
if (result == NULL)
goto onError;
if (result == Py_None) {
@ -182,11 +175,9 @@ PyObject *_PyCodec_Lookup(const char *encoding)
Py_DECREF(result);
goto onError;
}
Py_DECREF(args);
return result;
onError:
Py_XDECREF(args);
return NULL;
}
@ -325,7 +316,7 @@ PyObject *codec_getstreamcodec(const char *encoding,
if (errors != NULL)
streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
else
streamcodec = PyObject_CallFunctionObjArgs(codeccls, stream, NULL);
streamcodec = _PyObject_CallOneArg(codeccls, stream);
Py_DECREF(codecs);
return streamcodec;
}

View file

@ -93,7 +93,7 @@ _PyErr_CreateException(PyObject *exception, PyObject *value)
return PyObject_Call(exception, value, NULL);
}
else {
return PyObject_CallFunctionObjArgs(exception, value, NULL);
return _PyObject_CallOneArg(exception, value);
}
}
@ -1381,8 +1381,7 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, PyObject *obj)
hook_args = make_unraisable_hook_args(tstate, exc_type, exc_value,
exc_tb, err_msg, obj);
if (hook_args != NULL) {
PyObject *args[1] = {hook_args};
PyObject *res = _PyObject_FastCall(hook, args, 1);
PyObject *res = _PyObject_CallOneArg(hook, hook_args);
Py_DECREF(hook_args);
if (res != NULL) {
Py_DECREF(res);

View file

@ -1180,7 +1180,7 @@ get_path_importer(PyThreadState *tstate, PyObject *path_importer_cache,
PyObject *hook = PyList_GetItem(path_hooks, j);
if (hook == NULL)
return NULL;
importer = PyObject_CallFunctionObjArgs(hook, p, NULL);
importer = _PyObject_CallOneArg(hook, p);
if (importer != NULL)
break;