From 196a530e00d88a138973bf9182e013937e293f97 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Thu, 4 Jul 2019 12:31:34 +0200 Subject: bpo-37483: add _PyObject_CallOneArg() function (#14558) --- Doc/c-api/object.rst | 11 +++++++++++ Include/cpython/abstract.h | 12 ++++++++++++ .../C API/2019-07-02-15-42-37.bpo-37483.vftT4f.rst | 2 ++ Modules/_asynciomodule.c | 21 +++++++++------------ Modules/_collectionsmodule.c | 3 +-- Modules/_csv.c | 2 +- Modules/_ctypes/callproc.c | 8 ++++---- Modules/_elementtree.c | 16 ++++++++-------- Modules/_io/iobase.c | 2 +- Modules/_json.c | 12 ++++++------ Modules/_pickle.c | 12 +++++------- Modules/_sqlite/cache.c | 6 ++++-- Modules/_sqlite/connection.c | 13 +++---------- Modules/_sqlite/cursor.c | 2 +- Modules/_sqlite/microprotocols.c | 6 +++--- Modules/_sre.c | 2 +- Modules/_struct.c | 2 +- Modules/_xxtestfuzz/fuzzer.c | 4 ++-- Modules/cjkcodecs/cjkcodecs.h | 2 +- Modules/cjkcodecs/multibytecodec.c | 14 ++------------ Modules/gcmodule.c | 2 +- Modules/itertoolsmodule.c | 8 ++++---- Modules/pyexpat.c | 2 +- Objects/abstract.c | 10 +++++----- Objects/bytearrayobject.c | 6 ++---- Objects/bytesobject.c | 3 +-- Objects/descrobject.c | 5 ++--- Objects/dictobject.c | 3 +-- Objects/fileobject.c | 2 +- Objects/floatobject.c | 2 +- Objects/genobject.c | 8 ++++---- Objects/listobject.c | 3 +-- Objects/longobject.c | 3 +-- Objects/memoryobject.c | 4 ++-- Objects/moduleobject.c | 3 +-- Objects/typeobject.c | 5 ++--- Objects/unicodeobject.c | 10 ++++------ Objects/weakrefobject.c | 2 +- Python/_warnings.c | 8 ++++---- Python/bltinmodule.c | 9 ++++----- Python/ceval.c | 2 +- Python/codecs.c | 15 +++------------ Python/errors.c | 5 ++--- Python/import.c | 2 +- 44 files changed, 128 insertions(+), 146 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2019-07-02-15-42-37.bpo-37483.vftT4f.rst diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index a84235b..6d13855 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -264,6 +264,17 @@ Object Protocol .. versionadded:: 3.9 +.. c:function:: PyObject* _PyObject_CallOneArg(PyObject *callable, PyObject *arg) + + Call a callable Python object *callable* with exactly 1 positional argument + *arg* and no keyword arguments. + + Return the result of the call on success, or raise an exception and return + *NULL* on failure. + + .. versionadded:: 3.9 + + .. c:function:: PyObject* PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs) Call a callable Python object *callable*, with arguments given by the diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 69ed943..c9a8a07 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -62,6 +62,7 @@ PyVectorcall_NARGS(size_t n) static inline vectorcallfunc _PyVectorcall_Function(PyObject *callable) { + assert(callable != NULL); PyTypeObject *tp = Py_TYPE(callable); if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; @@ -134,6 +135,17 @@ _PyObject_CallNoArg(PyObject *func) { return _PyObject_Vectorcall(func, NULL, 0, NULL); } +static inline PyObject * +_PyObject_CallOneArg(PyObject *func, PyObject *arg) +{ + assert(arg != NULL); + PyObject *_args[2]; + PyObject **args = _args + 1; // For PY_VECTORCALL_ARGUMENTS_OFFSET + args[0] = arg; + return _PyObject_Vectorcall(func, args, + 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); +} + PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend( PyObject *callable, PyObject *obj, diff --git a/Misc/NEWS.d/next/C API/2019-07-02-15-42-37.bpo-37483.vftT4f.rst b/Misc/NEWS.d/next/C API/2019-07-02-15-42-37.bpo-37483.vftT4f.rst new file mode 100644 index 0000000..e2b0201 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-07-02-15-42-37.bpo-37483.vftT4f.rst @@ -0,0 +1,2 @@ +Add new function ``_PyObject_CallOneArg`` for calling an object with one +positional argument. diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 4caf3a4..443acc5 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -141,8 +141,7 @@ _is_coroutine(PyObject *coro) Do this check after 'future_init()'; in case we need to raise an error, __del__ needs a properly initialized object. */ - PyObject *res = PyObject_CallFunctionObjArgs( - asyncio_iscoroutine_func, coro, NULL); + PyObject *res = _PyObject_CallOneArg(asyncio_iscoroutine_func, coro); if (res == NULL) { return -1; } @@ -1286,8 +1285,7 @@ static PyObject * _asyncio_Future__repr_info_impl(FutureObj *self) /*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/ { - return PyObject_CallFunctionObjArgs( - asyncio_future_repr_info_func, self, NULL); + return _PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self); } static PyObject * @@ -1364,7 +1362,7 @@ FutureObj_finalize(FutureObj *fut) func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = PyObject_CallFunctionObjArgs(func, context, NULL); + PyObject *res = _PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2104,13 +2102,13 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop) Py_DECREF(current_task_func); return NULL; } - ret = PyObject_CallFunctionObjArgs(current_task_func, loop, NULL); + ret = _PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); Py_DECREF(loop); return ret; } else { - ret = PyObject_CallFunctionObjArgs(current_task_func, loop, NULL); + ret = _PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); return ret; } @@ -2146,7 +2144,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop) return NULL; } - res = PyObject_CallFunctionObjArgs(all_tasks_func, loop, NULL); + res = _PyObject_CallOneArg(all_tasks_func, loop); Py_DECREF(all_tasks_func); return res; } @@ -2159,8 +2157,7 @@ static PyObject * _asyncio_Task__repr_info_impl(TaskObj *self) /*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/ { - return PyObject_CallFunctionObjArgs( - asyncio_task_repr_info_func, self, NULL); + return _PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self); } /*[clinic input] @@ -2411,7 +2408,7 @@ TaskObj_finalize(TaskObj *task) func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = PyObject_CallFunctionObjArgs(func, context, NULL); + PyObject *res = _PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2543,7 +2540,7 @@ task_set_error_soon(TaskObj *task, PyObject *et, const char *format, ...) return NULL; } - PyObject *e = PyObject_CallFunctionObjArgs(et, msg, NULL); + PyObject *e = _PyObject_CallOneArg(et, msg); Py_DECREF(msg); if (e == NULL) { return NULL; diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 45169ec..cc7d3cf 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -512,8 +512,7 @@ deque_copy(PyObject *deque, PyObject *Py_UNUSED(ignored)) return NULL; } if (old_deque->maxlen < 0) - result = PyObject_CallFunctionObjArgs((PyObject *)(Py_TYPE(deque)), - deque, NULL); + result = _PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque); else result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, old_deque->maxlen, NULL); diff --git a/Modules/_csv.c b/Modules/_csv.c index 014cbb4..9653ff9 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -1240,7 +1240,7 @@ csv_writerow(WriterObj *self, PyObject *seq) if (line == NULL) { return NULL; } - result = PyObject_CallFunctionObjArgs(self->write, line, NULL); + result = _PyObject_CallOneArg(self->write, line); Py_DECREF(line); return result; } diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 6766524..973a654 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -925,7 +925,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) if (!checker || !retval) return retval; - v = PyObject_CallFunctionObjArgs(checker, retval, NULL); + v = _PyObject_CallOneArg(checker, retval); if (v == NULL) _PyTraceback_Add("GetResult", "_ctypes/callproc.c", __LINE__-2); Py_DECREF(retval); @@ -1118,7 +1118,7 @@ PyObject *_ctypes_callproc(PPROC pProc, if (argtypes && argtype_count > i) { PyObject *v; converter = PyTuple_GET_ITEM(argtypes, i); - v = PyObject_CallFunctionObjArgs(converter, arg, NULL); + v = _PyObject_CallOneArg(converter, arg); if (v == NULL) { _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1); goto cleanup; @@ -1795,7 +1795,7 @@ pointer(PyObject *self, PyObject *arg) typ = PyDict_GetItemWithError(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg)); if (typ) { - return PyObject_CallFunctionObjArgs(typ, arg, NULL); + return _PyObject_CallOneArg(typ, arg); } else if (PyErr_Occurred()) { return NULL; @@ -1803,7 +1803,7 @@ pointer(PyObject *self, PyObject *arg) typ = POINTER(NULL, (PyObject *)Py_TYPE(arg)); if (typ == NULL) return NULL; - result = PyObject_CallFunctionObjArgs(typ, arg, NULL); + result = _PyObject_CallOneArg(typ, arg); Py_DECREF(typ); return result; } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index ee1b5e5..b93ec3d 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2696,7 +2696,7 @@ treebuilder_append_event(TreeBuilderObject *self, PyObject *action, PyObject *event = PyTuple_Pack(2, action, node); if (event == NULL) return -1; - res = _PyObject_FastCall(self->events_append, &event, 1); + res = _PyObject_CallOneArg(self->events_append, event); Py_DECREF(event); if (res == NULL) return -1; @@ -2859,7 +2859,7 @@ treebuilder_handle_comment(TreeBuilderObject* self, PyObject* text) } if (self->comment_factory) { - comment = _PyObject_FastCall(self->comment_factory, &text, 1); + comment = _PyObject_CallOneArg(self->comment_factory, text); if (!comment) return NULL; @@ -3197,7 +3197,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column, if (errmsg == NULL) return; - error = _PyObject_FastCall(st->parseerror_obj, &errmsg, 1); + error = _PyObject_CallOneArg(st->parseerror_obj, errmsg); Py_DECREF(errmsg); if (!error) return; @@ -3260,7 +3260,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in, (TreeBuilderObject*) self->target, value ); else if (self->handle_data) - res = _PyObject_FastCall(self->handle_data, &value, 1); + res = _PyObject_CallOneArg(self->handle_data, value); else res = NULL; Py_XDECREF(res); @@ -3371,7 +3371,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in, /* shortcut */ res = treebuilder_handle_data((TreeBuilderObject*) self->target, data); else if (self->handle_data) - res = _PyObject_FastCall(self->handle_data, &data, 1); + res = _PyObject_CallOneArg(self->handle_data, data); else res = NULL; @@ -3398,7 +3398,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in) else if (self->handle_end) { tag = makeuniversal(self, tag_in); if (tag) { - res = _PyObject_FastCall(self->handle_end, &tag, 1); + res = _PyObject_CallOneArg(self->handle_end, tag); Py_DECREF(tag); } } @@ -3485,7 +3485,7 @@ expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) if (!prefix) return; - res = _PyObject_FastCall(self->handle_end_ns, &prefix, 1); + res = _PyObject_CallOneArg(self->handle_end_ns, prefix); Py_DECREF(prefix); } @@ -3515,7 +3515,7 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in) if (!comment) return; - res = _PyObject_FastCall(self->handle_comment, &comment, 1); + res = _PyObject_CallOneArg(self->handle_comment, comment); } Py_XDECREF(res); diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index fab4509..82cc776 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -557,7 +557,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) PyObject *b; if (peek != NULL) { - PyObject *readahead = PyObject_CallFunctionObjArgs(peek, _PyLong_One, NULL); + PyObject *readahead = _PyObject_CallOneArg(peek, _PyLong_One); if (readahead == NULL) { /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() when EINTR occurs so we needn't do it ourselves. */ diff --git a/Modules/_json.c b/Modules/_json.c index e3aa997..38beb6f 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -818,14 +818,14 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss *next_idx_ptr = idx + 1; if (has_pairs_hook) { - val = PyObject_CallFunctionObjArgs(s->object_pairs_hook, rval, NULL); + val = _PyObject_CallOneArg(s->object_pairs_hook, rval); Py_DECREF(rval); return val; } /* if object_hook is not None: rval = object_hook(rval) */ if (s->object_hook != Py_None) { - val = PyObject_CallFunctionObjArgs(s->object_hook, rval, NULL); + val = _PyObject_CallOneArg(s->object_hook, rval); Py_DECREF(rval); return val; } @@ -931,7 +931,7 @@ _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssi return NULL; /* rval = parse_constant(constant) */ - rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL); + rval = _PyObject_CallOneArg(s->parse_constant, cstr); idx += PyUnicode_GET_LENGTH(cstr); Py_DECREF(cstr); *next_idx_ptr = idx; @@ -1030,7 +1030,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ idx - start); if (numstr == NULL) return NULL; - rval = PyObject_CallFunctionObjArgs(custom_func, numstr, NULL); + rval = _PyObject_CallOneArg(custom_func, numstr); } else { Py_ssize_t i, n; @@ -1440,7 +1440,7 @@ encoder_encode_string(PyEncoderObject *s, PyObject *obj) if (s->fast_encode) { return s->fast_encode(NULL, obj); } - encoded = PyObject_CallFunctionObjArgs(s->encoder, obj, NULL); + encoded = _PyObject_CallOneArg(s->encoder, obj); if (encoded != NULL && !PyUnicode_Check(encoded)) { PyErr_Format(PyExc_TypeError, "encoder() must return a string, not %.80s", @@ -1526,7 +1526,7 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc, return -1; } } - newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL); + newobj = _PyObject_CallOneArg(s->defaultfn, obj); if (newobj == NULL) { Py_XDECREF(ident); return -1; diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 3adece0..d6d1250 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -359,7 +359,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj) { PyObject *result; - result = PyObject_CallFunctionObjArgs(func, obj, NULL); + result = _PyObject_CallOneArg(func, obj); Py_DECREF(obj); return result; } @@ -420,7 +420,7 @@ call_method(PyObject *func, PyObject *self, PyObject *obj) return PyObject_CallFunctionObjArgs(func, self, obj, NULL); } else { - return PyObject_CallFunctionObjArgs(func, obj, NULL); + return _PyObject_CallOneArg(func, obj); } } @@ -2296,7 +2296,7 @@ _Pickler_write_bytes(PicklerObject *self, return -1; } } - result = PyObject_CallFunctionObjArgs(self->write, payload, NULL); + result = _PyObject_CallOneArg(self->write, payload); Py_XDECREF(mem); if (result == NULL) { return -1; @@ -2504,8 +2504,7 @@ save_picklebuffer(PicklerObject *self, PyObject *obj) } int in_band = 1; if (self->buffer_callback != NULL) { - PyObject *ret = PyObject_CallFunctionObjArgs(self->buffer_callback, - obj, NULL); + PyObject *ret = _PyObject_CallOneArg(self->buffer_callback, obj); if (ret == NULL) { return -1; } @@ -4322,8 +4321,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save) * regular reduction mechanism. */ if (self->reducer_override != NULL) { - reduce_value = PyObject_CallFunctionObjArgs(self->reducer_override, - obj, NULL); + reduce_value = _PyObject_CallOneArg(self->reducer_override, obj); if (reduce_value == NULL) { goto error; } diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 4d41804..7552d1b 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -112,9 +112,8 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self) Py_TYPE(self)->tp_free((PyObject*)self); } -PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) +PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key) { - PyObject* key = args; pysqlite_Node* node; pysqlite_Node* ptr; PyObject* data; @@ -184,6 +183,9 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) } } + /* We cannot replace this by _PyObject_CallOneArg() since + * PyObject_CallFunction() has a special case when using a + * single tuple as argument. */ data = PyObject_CallFunction(self->factory, "O", key); if (!data) { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 5ceeaf9..08604b9 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -310,7 +310,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, factory = (PyObject*)&pysqlite_CursorType; } - cursor = PyObject_CallFunctionObjArgs(factory, (PyObject *)self, NULL); + cursor = _PyObject_CallOneArg(factory, (PyObject *)self); if (cursor == NULL) return NULL; if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) { @@ -970,7 +970,7 @@ static void _trace_callback(void* user_arg, const char* statement_string) py_statement = PyUnicode_DecodeUTF8(statement_string, strlen(statement_string), "replace"); if (py_statement) { - ret = PyObject_CallFunctionObjArgs((PyObject*)user_arg, py_statement, NULL); + ret = _PyObject_CallOneArg((PyObject*)user_arg, py_statement); Py_DECREF(py_statement); } @@ -1465,16 +1465,9 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args) goto finally; } - args = PyTuple_New(1); - if (!args) { - goto finally; - } - Py_INCREF(self); - PyTuple_SetItem(args, 0, (PyObject*)self); - retval = PyObject_CallObject(pyfn_iterdump, args); + retval = _PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); finally: - Py_XDECREF(args); Py_XDECREF(module); return retval; } diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 38d94b2..e6fcac8 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -266,7 +266,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) item = PyBytes_FromStringAndSize(val_str, nbytes); if (!item) goto error; - converted = PyObject_CallFunction(converter, "O", item); + converted = _PyObject_CallOneArg(converter, item); Py_DECREF(item); } } else { diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index c23b09f..59a5e22 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -92,7 +92,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) Py_DECREF(key); if (adapter) { Py_INCREF(adapter); - adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); return adapted; } @@ -105,7 +105,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); if (adapted == Py_None) { @@ -124,7 +124,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallFunctionObjArgs(adapter, proto, NULL); + adapted = _PyObject_CallOneArg(adapter, proto); Py_DECREF(adapter); if (adapted == Py_None) { diff --git a/Modules/_sre.c b/Modules/_sre.c index d4fe588..f4f9d01 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1082,7 +1082,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string, match = pattern_new_match(self, &state, 1); if (!match) goto error; - item = PyObject_CallFunctionObjArgs(filter, match, NULL); + item = _PyObject_CallOneArg(filter, match); Py_DECREF(match); if (!item) goto error; diff --git a/Modules/_struct.c b/Modules/_struct.c index 9281c68..d1c635a 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2098,7 +2098,7 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr) return 0; } - s_object = PyObject_CallFunctionObjArgs((PyObject *)(&PyStructType), fmt, NULL); + s_object = _PyObject_CallOneArg((PyObject *)(&PyStructType), fmt); if (s_object != NULL) { if (PyDict_GET_SIZE(cache) >= MAXCACHE) PyDict_Clear(cache); diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c index 16104e4..2446e71 100644 --- a/Modules/_xxtestfuzz/fuzzer.c +++ b/Modules/_xxtestfuzz/fuzzer.c @@ -104,7 +104,7 @@ static int fuzz_json_loads(const char* data, size_t size) { if (input_bytes == NULL) { return 0; } - PyObject* parsed = PyObject_CallFunctionObjArgs(json_loads_method, input_bytes, NULL); + PyObject* parsed = _PyObject_CallOneArg(json_loads_method, input_bytes); if (parsed == NULL) { /* Ignore ValueError as the fuzzer will more than likely generate some invalid json and values */ @@ -263,7 +263,7 @@ static int fuzz_sre_match(const char* data, size_t size) { PyObject* pattern = compiled_patterns[idx]; PyObject* match_callable = PyObject_GetAttrString(pattern, "match"); - PyObject* matches = PyObject_CallFunctionObjArgs(match_callable, to_match, NULL); + PyObject* matches = _PyObject_CallOneArg(match_callable, to_match); Py_XDECREF(matches); Py_DECREF(match_callable); diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index b67f348..7ed8365 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -291,7 +291,7 @@ getcodec(PyObject *self, PyObject *encoding) if (codecobj == NULL) return NULL; - r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); + r = _PyObject_CallOneArg(cofunc, codecobj); Py_DECREF(codecobj); return r; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index c01a0e5..052ed88 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -81,7 +81,7 @@ internal_error_callback(const char *errors) static PyObject * call_error_callback(PyObject *errors, PyObject *exc) { - PyObject *args, *cb, *r; + PyObject *cb, *r; const char *str; assert(PyUnicode_Check(errors)); @@ -92,17 +92,7 @@ call_error_callback(PyObject *errors, PyObject *exc) if (cb == NULL) return NULL; - args = PyTuple_New(1); - if (args == NULL) { - Py_DECREF(cb); - return NULL; - } - - PyTuple_SET_ITEM(args, 0, exc); - Py_INCREF(exc); - - r = PyObject_CallObject(cb, args); - Py_DECREF(args); + r = _PyObject_CallOneArg(cb, exc); Py_DECREF(cb); return r; } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 0cf00e8..2ee7651 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -763,7 +763,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) _PyObject_ASSERT(op, callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = PyObject_CallFunctionObjArgs(callback, wr, NULL); + temp = _PyObject_CallOneArg(callback, (PyObject *)wr); if (temp == NULL) PyErr_WriteUnraisable(callback); else diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 00e3cbb..781d0cc 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -134,7 +134,7 @@ groupby_step(groupbyobject *gbo) newkey = newvalue; Py_INCREF(newvalue); } else { - newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL); + newkey = _PyObject_CallOneArg(gbo->keyfunc, newvalue); if (newkey == NULL) { Py_DECREF(newvalue); return -1; @@ -1210,7 +1210,7 @@ dropwhile_next(dropwhileobject *lz) if (lz->start == 1) return item; - good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1373,7 +1373,7 @@ takewhile_next(takewhileobject *lz) if (item == NULL) return NULL; - good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -3906,7 +3906,7 @@ filterfalse_next(filterfalseobject *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; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 45a1e68..3d193e7 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code) XML_ErrorString(code), lineno, column); if (buffer == NULL) return NULL; - err = PyObject_CallFunctionObjArgs(ErrorObject, buffer, NULL); + err = _PyObject_CallOneArg(ErrorObject, buffer); Py_DECREF(buffer); if ( err != NULL && set_error_attr(err, "code", code) diff --git a/Objects/abstract.c b/Objects/abstract.c index 77d0914..86178a7 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -172,13 +172,13 @@ PyObject_GetItem(PyObject *o, PyObject *key) } if (PyType_Check(o)) { - PyObject *meth, *result, *stack[1] = {key}; + PyObject *meth, *result; _Py_IDENTIFIER(__class_getitem__); if (_PyObject_LookupAttrId(o, &PyId___class_getitem__, &meth) < 0) { return NULL; } if (meth) { - result = _PyObject_FastCall(meth, stack, 1); + result = _PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } @@ -737,7 +737,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec) } /* And call it. */ - result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL); + result = _PyObject_CallOneArg(meth, format_spec); Py_DECREF(meth); if (result && !PyUnicode_Check(result)) { @@ -2459,7 +2459,7 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls) Py_DECREF(checker); return ok; } - res = PyObject_CallFunctionObjArgs(checker, inst, NULL); + res = _PyObject_CallOneArg(checker, inst); Py_LeaveRecursiveCall(); Py_DECREF(checker); if (res != NULL) { @@ -2533,7 +2533,7 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls) Py_DECREF(checker); return ok; } - res = PyObject_CallFunctionObjArgs(checker, derived, NULL); + res = _PyObject_CallOneArg(checker, derived); Py_LeaveRecursiveCall(); Py_DECREF(checker); if (res != NULL) { diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 1bb19a9..9dd6712 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -89,8 +89,7 @@ _canresize(PyByteArrayObject *self) PyObject * PyByteArray_FromObject(PyObject *input) { - return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type, - input, NULL); + return _PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input); } static PyObject * @@ -2018,8 +2017,7 @@ bytearray_fromhex_impl(PyTypeObject *type, PyObject *string) { PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type); if (type != &PyByteArray_Type && result != NULL) { - Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, - result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 06c87b0..c4edcca 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2333,8 +2333,7 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string) { PyObject *result = _PyBytes_FromHex(string, 0); if (type != &PyBytes_Type && result != NULL) { - Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, - result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a0eb505..4b98578 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1340,8 +1340,7 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) return NULL; } - PyObject *args[1] = {obj}; - return _PyObject_FastCall(gs->prop_get, args, 1); + return _PyObject_CallOneArg(gs->prop_get, obj); } static int @@ -1362,7 +1361,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) return -1; } if (value == NULL) - res = PyObject_CallFunctionObjArgs(func, obj, NULL); + res = _PyObject_CallOneArg(func, obj); else res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); if (res == NULL) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 0cc1443..422f4b0 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2113,8 +2113,7 @@ dict_subscript(PyDictObject *mp, PyObject *key) _Py_IDENTIFIER(__missing__); missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__); if (missing != NULL) { - res = PyObject_CallFunctionObjArgs(missing, - key, NULL); + res = _PyObject_CallOneArg(missing, key); Py_DECREF(missing); return res; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 3791241..a21e490 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -136,7 +136,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) Py_DECREF(writer); return -1; } - result = PyObject_CallFunctionObjArgs(writer, value, NULL); + result = _PyObject_CallOneArg(writer, value); Py_DECREF(value); Py_DECREF(writer); if (result == NULL) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 15cbe5c..689e929 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1501,7 +1501,7 @@ float_fromhex(PyTypeObject *type, PyObject *string) goto parse_error; result = PyFloat_FromDouble(negate ? -x : x); if (type != &PyFloat_Type && result != NULL) { - Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; diff --git a/Objects/genobject.c b/Objects/genobject.c index 2d9a286..5d1f9c7 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -57,7 +57,7 @@ _PyGen_Finalize(PyObject *self) /* Save the current exception, if any. */ PyErr_Fetch(&error_type, &error_value, &error_traceback); - res = PyObject_CallFunctionObjArgs(finalizer, self, NULL); + res = _PyObject_CallOneArg(finalizer, self); if (res == NULL) { PyErr_WriteUnraisable(self); @@ -562,7 +562,7 @@ _PyGen_SetStopIterationValue(PyObject *value) return 0; } /* Construct an exception instance manually with - * PyObject_CallFunctionObjArgs and pass it to PyErr_SetObject. + * _PyObject_CallOneArg and pass it to PyErr_SetObject. * * We do this to handle a situation when "value" is a tuple, in which * case PyErr_SetObject would set the value of StopIteration to @@ -570,7 +570,7 @@ _PyGen_SetStopIterationValue(PyObject *value) * * (See PyErr_SetObject/_PyErr_CreateException code for details.) */ - e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL); + e = _PyObject_CallOneArg(PyExc_StopIteration, value); if (e == NULL) { return -1; } @@ -1279,7 +1279,7 @@ async_gen_init_hooks(PyAsyncGenObject *o) PyObject *res; Py_INCREF(firstiter); - res = PyObject_CallFunctionObjArgs(firstiter, o, NULL); + res = _PyObject_CallOneArg(firstiter, (PyObject *)o); Py_DECREF(firstiter); if (res == NULL) { return 1; diff --git a/Objects/listobject.c b/Objects/listobject.c index f8bf45e..d012ab9 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2258,8 +2258,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse) } for (i = 0; i < saved_ob_size ; i++) { - keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i], - NULL); + keys[i] = _PyObject_CallOneArg(keyfunc, saved_ob_item[i]); if (keys[i] == NULL) { for (i=i-1 ; i>=0 ; i--) Py_DECREF(keys[i]); diff --git a/Objects/longobject.c b/Objects/longobject.c index 50ea2a4..3978f5c 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5611,8 +5611,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj, Py_DECREF(bytes); if (long_obj != NULL && type != &PyLong_Type) { - Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type, - long_obj, NULL)); + Py_SETREF(long_obj, _PyObject_CallOneArg((PyObject *)type, long_obj)); } return long_obj; diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index a873ac1..66920eaf 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1962,7 +1962,7 @@ struct_get_unpacker(const char *fmt, Py_ssize_t itemsize) if (format == NULL) goto error; - structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL); + structobj = _PyObject_CallOneArg(Struct, format); if (structobj == NULL) goto error; @@ -2001,7 +2001,7 @@ struct_unpack_single(const char *ptr, struct unpacker *x) PyObject *v; memcpy(x->item, ptr, x->itemsize); - v = PyObject_CallFunctionObjArgs(x->unpack_from, x->mview, NULL); + v = _PyObject_CallOneArg(x->unpack_from, x->mview); if (v == NULL) return NULL; diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 85134c7..92f97e6 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -736,8 +736,7 @@ module_getattro(PyModuleObject *m, PyObject *name) _Py_IDENTIFIER(__getattr__); getattr = _PyDict_GetItemId(m->md_dict, &PyId___getattr__); if (getattr) { - PyObject* stack[1] = {name}; - return _PyObject_FastCall(getattr, stack, 1); + return _PyObject_CallOneArg(getattr, name); } _Py_IDENTIFIER(__name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f814333..3b9a537 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1459,8 +1459,7 @@ static PyObject* call_unbound_noarg(int unbound, PyObject *func, PyObject *self) { if (unbound) { - PyObject *args[1] = {self}; - return _PyObject_FastCall(func, args, 1); + return _PyObject_CallOneArg(func, self); } else { return _PyObject_CallNoArg(func); @@ -6561,7 +6560,7 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name) else attr = descr; } - res = PyObject_CallFunctionObjArgs(attr, name, NULL); + res = _PyObject_CallOneArg(attr, name); Py_XDECREF(descr); return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 51d314b..5545eae 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4248,7 +4248,7 @@ unicode_decode_call_errorhandler_wchar( if (*exceptionObject == NULL) goto onError; - restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -4352,7 +4352,7 @@ unicode_decode_call_errorhandler_writer( if (*exceptionObject == NULL) goto onError; - restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -6799,8 +6799,7 @@ unicode_encode_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = PyObject_CallFunctionObjArgs( - *errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { @@ -8778,8 +8777,7 @@ unicode_translate_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = PyObject_CallFunctionObjArgs( - *errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 8b8e710..ae3f6dc 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -874,7 +874,7 @@ PyWeakref_GetObject(PyObject *ref) static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); + PyObject *cbresult = _PyObject_CallOneArg(callback, (PyObject *)ref); if (cbresult == NULL) PyErr_WriteUnraisable(callback); 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; -- cgit v0.12