diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-07-04 10:31:34 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-07-04 10:31:34 (GMT) |
commit | 196a530e00d88a138973bf9182e013937e293f97 (patch) | |
tree | 35443abb5aa148b459f68ae43a18cdbb0627ba76 /Python | |
parent | 9d40554e0da09a44a8547f3f3a2b9dedfeaf7928 (diff) | |
download | cpython-196a530e00d88a138973bf9182e013937e293f97.zip cpython-196a530e00d88a138973bf9182e013937e293f97.tar.gz cpython-196a530e00d88a138973bf9182e013937e293f97.tar.bz2 |
bpo-37483: add _PyObject_CallOneArg() function (#14558)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 8 | ||||
-rw-r--r-- | Python/bltinmodule.c | 9 | ||||
-rw-r--r-- | Python/ceval.c | 2 | ||||
-rw-r--r-- | Python/codecs.c | 15 | ||||
-rw-r--r-- | Python/errors.c | 5 | ||||
-rw-r--r-- | Python/import.c | 2 |
6 files changed, 15 insertions, 26 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 0b19258..b1762e6 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -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; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 90fbb44..5de4363 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -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; } diff --git a/Python/ceval.c b/Python/ceval.c index 888749b..b0fd6ee 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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; diff --git a/Python/codecs.c b/Python/codecs.c index d4b34f8..3865762 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -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; } diff --git a/Python/errors.c b/Python/errors.c index b3b9ac9..a7d40c1 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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); diff --git a/Python/import.c b/Python/import.c index 3937fbe..76866ae 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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; |