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

@ -264,6 +264,17 @@ Object Protocol
.. versionadded:: 3.9 .. 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) .. c:function:: PyObject* PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
Call a callable Python object *callable*, with arguments given by the Call a callable Python object *callable*, with arguments given by the

View File

@ -62,6 +62,7 @@ PyVectorcall_NARGS(size_t n)
static inline vectorcallfunc static inline vectorcallfunc
_PyVectorcall_Function(PyObject *callable) _PyVectorcall_Function(PyObject *callable)
{ {
assert(callable != NULL);
PyTypeObject *tp = Py_TYPE(callable); PyTypeObject *tp = Py_TYPE(callable);
if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) { if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) {
return NULL; return NULL;
@ -134,6 +135,17 @@ _PyObject_CallNoArg(PyObject *func) {
return _PyObject_Vectorcall(func, NULL, 0, NULL); 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( PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
PyObject *callable, PyObject *callable,
PyObject *obj, PyObject *obj,

View File

@ -0,0 +1,2 @@
Add new function ``_PyObject_CallOneArg`` for calling an object with one
positional argument.

View File

@ -141,8 +141,7 @@ _is_coroutine(PyObject *coro)
Do this check after 'future_init()'; in case we need to raise Do this check after 'future_init()'; in case we need to raise
an error, __del__ needs a properly initialized object. an error, __del__ needs a properly initialized object.
*/ */
PyObject *res = PyObject_CallFunctionObjArgs( PyObject *res = _PyObject_CallOneArg(asyncio_iscoroutine_func, coro);
asyncio_iscoroutine_func, coro, NULL);
if (res == NULL) { if (res == NULL) {
return -1; return -1;
} }
@ -1286,8 +1285,7 @@ static PyObject *
_asyncio_Future__repr_info_impl(FutureObj *self) _asyncio_Future__repr_info_impl(FutureObj *self)
/*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/ /*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/
{ {
return PyObject_CallFunctionObjArgs( return _PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self);
asyncio_future_repr_info_func, self, NULL);
} }
static PyObject * static PyObject *
@ -1364,7 +1362,7 @@ FutureObj_finalize(FutureObj *fut)
func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler); func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler);
if (func != NULL) { if (func != NULL) {
PyObject *res = PyObject_CallFunctionObjArgs(func, context, NULL); PyObject *res = _PyObject_CallOneArg(func, context);
if (res == NULL) { if (res == NULL) {
PyErr_WriteUnraisable(func); PyErr_WriteUnraisable(func);
} }
@ -2104,13 +2102,13 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop)
Py_DECREF(current_task_func); Py_DECREF(current_task_func);
return NULL; return NULL;
} }
ret = PyObject_CallFunctionObjArgs(current_task_func, loop, NULL); ret = _PyObject_CallOneArg(current_task_func, loop);
Py_DECREF(current_task_func); Py_DECREF(current_task_func);
Py_DECREF(loop); Py_DECREF(loop);
return ret; return ret;
} }
else { else {
ret = PyObject_CallFunctionObjArgs(current_task_func, loop, NULL); ret = _PyObject_CallOneArg(current_task_func, loop);
Py_DECREF(current_task_func); Py_DECREF(current_task_func);
return ret; return ret;
} }
@ -2146,7 +2144,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop)
return NULL; return NULL;
} }
res = PyObject_CallFunctionObjArgs(all_tasks_func, loop, NULL); res = _PyObject_CallOneArg(all_tasks_func, loop);
Py_DECREF(all_tasks_func); Py_DECREF(all_tasks_func);
return res; return res;
} }
@ -2159,8 +2157,7 @@ static PyObject *
_asyncio_Task__repr_info_impl(TaskObj *self) _asyncio_Task__repr_info_impl(TaskObj *self)
/*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/ /*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/
{ {
return PyObject_CallFunctionObjArgs( return _PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self);
asyncio_task_repr_info_func, self, NULL);
} }
/*[clinic input] /*[clinic input]
@ -2411,7 +2408,7 @@ TaskObj_finalize(TaskObj *task)
func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler); func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler);
if (func != NULL) { if (func != NULL) {
PyObject *res = PyObject_CallFunctionObjArgs(func, context, NULL); PyObject *res = _PyObject_CallOneArg(func, context);
if (res == NULL) { if (res == NULL) {
PyErr_WriteUnraisable(func); PyErr_WriteUnraisable(func);
} }
@ -2543,7 +2540,7 @@ task_set_error_soon(TaskObj *task, PyObject *et, const char *format, ...)
return NULL; return NULL;
} }
PyObject *e = PyObject_CallFunctionObjArgs(et, msg, NULL); PyObject *e = _PyObject_CallOneArg(et, msg);
Py_DECREF(msg); Py_DECREF(msg);
if (e == NULL) { if (e == NULL) {
return NULL; return NULL;

View File

@ -512,8 +512,7 @@ deque_copy(PyObject *deque, PyObject *Py_UNUSED(ignored))
return NULL; return NULL;
} }
if (old_deque->maxlen < 0) if (old_deque->maxlen < 0)
result = PyObject_CallFunctionObjArgs((PyObject *)(Py_TYPE(deque)), result = _PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque);
deque, NULL);
else else
result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
deque, old_deque->maxlen, NULL); deque, old_deque->maxlen, NULL);

View File

@ -1240,7 +1240,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
if (line == NULL) { if (line == NULL) {
return NULL; return NULL;
} }
result = PyObject_CallFunctionObjArgs(self->write, line, NULL); result = _PyObject_CallOneArg(self->write, line);
Py_DECREF(line); Py_DECREF(line);
return result; return result;
} }

View File

@ -925,7 +925,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
if (!checker || !retval) if (!checker || !retval)
return retval; return retval;
v = PyObject_CallFunctionObjArgs(checker, retval, NULL); v = _PyObject_CallOneArg(checker, retval);
if (v == NULL) if (v == NULL)
_PyTraceback_Add("GetResult", "_ctypes/callproc.c", __LINE__-2); _PyTraceback_Add("GetResult", "_ctypes/callproc.c", __LINE__-2);
Py_DECREF(retval); Py_DECREF(retval);
@ -1118,7 +1118,7 @@ PyObject *_ctypes_callproc(PPROC pProc,
if (argtypes && argtype_count > i) { if (argtypes && argtype_count > i) {
PyObject *v; PyObject *v;
converter = PyTuple_GET_ITEM(argtypes, i); converter = PyTuple_GET_ITEM(argtypes, i);
v = PyObject_CallFunctionObjArgs(converter, arg, NULL); v = _PyObject_CallOneArg(converter, arg);
if (v == NULL) { if (v == NULL) {
_ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1); _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1);
goto cleanup; goto cleanup;
@ -1795,7 +1795,7 @@ pointer(PyObject *self, PyObject *arg)
typ = PyDict_GetItemWithError(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg)); typ = PyDict_GetItemWithError(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg));
if (typ) { if (typ) {
return PyObject_CallFunctionObjArgs(typ, arg, NULL); return _PyObject_CallOneArg(typ, arg);
} }
else if (PyErr_Occurred()) { else if (PyErr_Occurred()) {
return NULL; return NULL;
@ -1803,7 +1803,7 @@ pointer(PyObject *self, PyObject *arg)
typ = POINTER(NULL, (PyObject *)Py_TYPE(arg)); typ = POINTER(NULL, (PyObject *)Py_TYPE(arg));
if (typ == NULL) if (typ == NULL)
return NULL; return NULL;
result = PyObject_CallFunctionObjArgs(typ, arg, NULL); result = _PyObject_CallOneArg(typ, arg);
Py_DECREF(typ); Py_DECREF(typ);
return result; return result;
} }

View File

@ -2696,7 +2696,7 @@ treebuilder_append_event(TreeBuilderObject *self, PyObject *action,
PyObject *event = PyTuple_Pack(2, action, node); PyObject *event = PyTuple_Pack(2, action, node);
if (event == NULL) if (event == NULL)
return -1; return -1;
res = _PyObject_FastCall(self->events_append, &event, 1); res = _PyObject_CallOneArg(self->events_append, event);
Py_DECREF(event); Py_DECREF(event);
if (res == NULL) if (res == NULL)
return -1; return -1;
@ -2859,7 +2859,7 @@ treebuilder_handle_comment(TreeBuilderObject* self, PyObject* text)
} }
if (self->comment_factory) { if (self->comment_factory) {
comment = _PyObject_FastCall(self->comment_factory, &text, 1); comment = _PyObject_CallOneArg(self->comment_factory, text);
if (!comment) if (!comment)
return NULL; 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) if (errmsg == NULL)
return; return;
error = _PyObject_FastCall(st->parseerror_obj, &errmsg, 1); error = _PyObject_CallOneArg(st->parseerror_obj, errmsg);
Py_DECREF(errmsg); Py_DECREF(errmsg);
if (!error) if (!error)
return; return;
@ -3260,7 +3260,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in,
(TreeBuilderObject*) self->target, value (TreeBuilderObject*) self->target, value
); );
else if (self->handle_data) else if (self->handle_data)
res = _PyObject_FastCall(self->handle_data, &value, 1); res = _PyObject_CallOneArg(self->handle_data, value);
else else
res = NULL; res = NULL;
Py_XDECREF(res); Py_XDECREF(res);
@ -3371,7 +3371,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in,
/* shortcut */ /* shortcut */
res = treebuilder_handle_data((TreeBuilderObject*) self->target, data); res = treebuilder_handle_data((TreeBuilderObject*) self->target, data);
else if (self->handle_data) else if (self->handle_data)
res = _PyObject_FastCall(self->handle_data, &data, 1); res = _PyObject_CallOneArg(self->handle_data, data);
else else
res = NULL; res = NULL;
@ -3398,7 +3398,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in)
else if (self->handle_end) { else if (self->handle_end) {
tag = makeuniversal(self, tag_in); tag = makeuniversal(self, tag_in);
if (tag) { if (tag) {
res = _PyObject_FastCall(self->handle_end, &tag, 1); res = _PyObject_CallOneArg(self->handle_end, tag);
Py_DECREF(tag); Py_DECREF(tag);
} }
} }
@ -3485,7 +3485,7 @@ expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in)
if (!prefix) if (!prefix)
return; return;
res = _PyObject_FastCall(self->handle_end_ns, &prefix, 1); res = _PyObject_CallOneArg(self->handle_end_ns, prefix);
Py_DECREF(prefix); Py_DECREF(prefix);
} }
@ -3515,7 +3515,7 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in)
if (!comment) if (!comment)
return; return;
res = _PyObject_FastCall(self->handle_comment, &comment, 1); res = _PyObject_CallOneArg(self->handle_comment, comment);
} }
Py_XDECREF(res); Py_XDECREF(res);

View File

@ -557,7 +557,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit)
PyObject *b; PyObject *b;
if (peek != NULL) { if (peek != NULL) {
PyObject *readahead = PyObject_CallFunctionObjArgs(peek, _PyLong_One, NULL); PyObject *readahead = _PyObject_CallOneArg(peek, _PyLong_One);
if (readahead == NULL) { if (readahead == NULL) {
/* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals()
when EINTR occurs so we needn't do it ourselves. */ when EINTR occurs so we needn't do it ourselves. */

View File

@ -818,14 +818,14 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss
*next_idx_ptr = idx + 1; *next_idx_ptr = idx + 1;
if (has_pairs_hook) { if (has_pairs_hook) {
val = PyObject_CallFunctionObjArgs(s->object_pairs_hook, rval, NULL); val = _PyObject_CallOneArg(s->object_pairs_hook, rval);
Py_DECREF(rval); Py_DECREF(rval);
return val; return val;
} }
/* if object_hook is not None: rval = object_hook(rval) */ /* if object_hook is not None: rval = object_hook(rval) */
if (s->object_hook != Py_None) { if (s->object_hook != Py_None) {
val = PyObject_CallFunctionObjArgs(s->object_hook, rval, NULL); val = _PyObject_CallOneArg(s->object_hook, rval);
Py_DECREF(rval); Py_DECREF(rval);
return val; return val;
} }
@ -931,7 +931,7 @@ _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssi
return NULL; return NULL;
/* rval = parse_constant(constant) */ /* rval = parse_constant(constant) */
rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL); rval = _PyObject_CallOneArg(s->parse_constant, cstr);
idx += PyUnicode_GET_LENGTH(cstr); idx += PyUnicode_GET_LENGTH(cstr);
Py_DECREF(cstr); Py_DECREF(cstr);
*next_idx_ptr = idx; *next_idx_ptr = idx;
@ -1030,7 +1030,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_
idx - start); idx - start);
if (numstr == NULL) if (numstr == NULL)
return NULL; return NULL;
rval = PyObject_CallFunctionObjArgs(custom_func, numstr, NULL); rval = _PyObject_CallOneArg(custom_func, numstr);
} }
else { else {
Py_ssize_t i, n; Py_ssize_t i, n;
@ -1440,7 +1440,7 @@ encoder_encode_string(PyEncoderObject *s, PyObject *obj)
if (s->fast_encode) { if (s->fast_encode) {
return s->fast_encode(NULL, obj); 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)) { if (encoded != NULL && !PyUnicode_Check(encoded)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"encoder() must return a string, not %.80s", "encoder() must return a string, not %.80s",
@ -1526,7 +1526,7 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc,
return -1; return -1;
} }
} }
newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL); newobj = _PyObject_CallOneArg(s->defaultfn, obj);
if (newobj == NULL) { if (newobj == NULL) {
Py_XDECREF(ident); Py_XDECREF(ident);
return -1; return -1;

View File

@ -359,7 +359,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj)
{ {
PyObject *result; PyObject *result;
result = PyObject_CallFunctionObjArgs(func, obj, NULL); result = _PyObject_CallOneArg(func, obj);
Py_DECREF(obj); Py_DECREF(obj);
return result; return result;
} }
@ -420,7 +420,7 @@ call_method(PyObject *func, PyObject *self, PyObject *obj)
return PyObject_CallFunctionObjArgs(func, self, obj, NULL); return PyObject_CallFunctionObjArgs(func, self, obj, NULL);
} }
else { else {
return PyObject_CallFunctionObjArgs(func, obj, NULL); return _PyObject_CallOneArg(func, obj);
} }
} }
@ -2296,7 +2296,7 @@ _Pickler_write_bytes(PicklerObject *self,
return -1; return -1;
} }
} }
result = PyObject_CallFunctionObjArgs(self->write, payload, NULL); result = _PyObject_CallOneArg(self->write, payload);
Py_XDECREF(mem); Py_XDECREF(mem);
if (result == NULL) { if (result == NULL) {
return -1; return -1;
@ -2504,8 +2504,7 @@ save_picklebuffer(PicklerObject *self, PyObject *obj)
} }
int in_band = 1; int in_band = 1;
if (self->buffer_callback != NULL) { if (self->buffer_callback != NULL) {
PyObject *ret = PyObject_CallFunctionObjArgs(self->buffer_callback, PyObject *ret = _PyObject_CallOneArg(self->buffer_callback, obj);
obj, NULL);
if (ret == NULL) { if (ret == NULL) {
return -1; return -1;
} }
@ -4322,8 +4321,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
* regular reduction mechanism. * regular reduction mechanism.
*/ */
if (self->reducer_override != NULL) { if (self->reducer_override != NULL) {
reduce_value = PyObject_CallFunctionObjArgs(self->reducer_override, reduce_value = _PyObject_CallOneArg(self->reducer_override, obj);
obj, NULL);
if (reduce_value == NULL) { if (reduce_value == NULL) {
goto error; goto error;
} }

View File

@ -112,9 +112,8 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self)
Py_TYPE(self)->tp_free((PyObject*)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* node;
pysqlite_Node* ptr; pysqlite_Node* ptr;
PyObject* data; 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); data = PyObject_CallFunction(self->factory, "O", key);
if (!data) { if (!data) {

View File

@ -310,7 +310,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
factory = (PyObject*)&pysqlite_CursorType; factory = (PyObject*)&pysqlite_CursorType;
} }
cursor = PyObject_CallFunctionObjArgs(factory, (PyObject *)self, NULL); cursor = _PyObject_CallOneArg(factory, (PyObject *)self);
if (cursor == NULL) if (cursor == NULL)
return NULL; return NULL;
if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) { 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, py_statement = PyUnicode_DecodeUTF8(statement_string,
strlen(statement_string), "replace"); strlen(statement_string), "replace");
if (py_statement) { if (py_statement) {
ret = PyObject_CallFunctionObjArgs((PyObject*)user_arg, py_statement, NULL); ret = _PyObject_CallOneArg((PyObject*)user_arg, py_statement);
Py_DECREF(py_statement); Py_DECREF(py_statement);
} }
@ -1465,16 +1465,9 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
goto finally; goto finally;
} }
args = PyTuple_New(1); retval = _PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self);
if (!args) {
goto finally;
}
Py_INCREF(self);
PyTuple_SetItem(args, 0, (PyObject*)self);
retval = PyObject_CallObject(pyfn_iterdump, args);
finally: finally:
Py_XDECREF(args);
Py_XDECREF(module); Py_XDECREF(module);
return retval; return retval;
} }

View File

@ -266,7 +266,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
item = PyBytes_FromStringAndSize(val_str, nbytes); item = PyBytes_FromStringAndSize(val_str, nbytes);
if (!item) if (!item)
goto error; goto error;
converted = PyObject_CallFunction(converter, "O", item); converted = _PyObject_CallOneArg(converter, item);
Py_DECREF(item); Py_DECREF(item);
} }
} else { } else {

View File

@ -92,7 +92,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
Py_DECREF(key); Py_DECREF(key);
if (adapter) { if (adapter) {
Py_INCREF(adapter); Py_INCREF(adapter);
adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); adapted = _PyObject_CallOneArg(adapter, obj);
Py_DECREF(adapter); Py_DECREF(adapter);
return adapted; return adapted;
} }
@ -105,7 +105,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
return NULL; return NULL;
} }
if (adapter) { if (adapter) {
adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); adapted = _PyObject_CallOneArg(adapter, obj);
Py_DECREF(adapter); Py_DECREF(adapter);
if (adapted == Py_None) { if (adapted == Py_None) {
@ -124,7 +124,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
return NULL; return NULL;
} }
if (adapter) { if (adapter) {
adapted = PyObject_CallFunctionObjArgs(adapter, proto, NULL); adapted = _PyObject_CallOneArg(adapter, proto);
Py_DECREF(adapter); Py_DECREF(adapter);
if (adapted == Py_None) { if (adapted == Py_None) {

View File

@ -1082,7 +1082,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
match = pattern_new_match(self, &state, 1); match = pattern_new_match(self, &state, 1);
if (!match) if (!match)
goto error; goto error;
item = PyObject_CallFunctionObjArgs(filter, match, NULL); item = _PyObject_CallOneArg(filter, match);
Py_DECREF(match); Py_DECREF(match);
if (!item) if (!item)
goto error; goto error;

View File

@ -2098,7 +2098,7 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
return 0; return 0;
} }
s_object = PyObject_CallFunctionObjArgs((PyObject *)(&PyStructType), fmt, NULL); s_object = _PyObject_CallOneArg((PyObject *)(&PyStructType), fmt);
if (s_object != NULL) { if (s_object != NULL) {
if (PyDict_GET_SIZE(cache) >= MAXCACHE) if (PyDict_GET_SIZE(cache) >= MAXCACHE)
PyDict_Clear(cache); PyDict_Clear(cache);

View File

@ -104,7 +104,7 @@ static int fuzz_json_loads(const char* data, size_t size) {
if (input_bytes == NULL) { if (input_bytes == NULL) {
return 0; return 0;
} }
PyObject* parsed = PyObject_CallFunctionObjArgs(json_loads_method, input_bytes, NULL); PyObject* parsed = _PyObject_CallOneArg(json_loads_method, input_bytes);
if (parsed == NULL) { if (parsed == NULL) {
/* Ignore ValueError as the fuzzer will more than likely /* Ignore ValueError as the fuzzer will more than likely
generate some invalid json and values */ 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* pattern = compiled_patterns[idx];
PyObject* match_callable = PyObject_GetAttrString(pattern, "match"); 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_XDECREF(matches);
Py_DECREF(match_callable); Py_DECREF(match_callable);

View File

@ -291,7 +291,7 @@ getcodec(PyObject *self, PyObject *encoding)
if (codecobj == NULL) if (codecobj == NULL)
return NULL; return NULL;
r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); r = _PyObject_CallOneArg(cofunc, codecobj);
Py_DECREF(codecobj); Py_DECREF(codecobj);
return r; return r;

View File

@ -81,7 +81,7 @@ internal_error_callback(const char *errors)
static PyObject * static PyObject *
call_error_callback(PyObject *errors, PyObject *exc) call_error_callback(PyObject *errors, PyObject *exc)
{ {
PyObject *args, *cb, *r; PyObject *cb, *r;
const char *str; const char *str;
assert(PyUnicode_Check(errors)); assert(PyUnicode_Check(errors));
@ -92,17 +92,7 @@ call_error_callback(PyObject *errors, PyObject *exc)
if (cb == NULL) if (cb == NULL)
return NULL; return NULL;
args = PyTuple_New(1); r = _PyObject_CallOneArg(cb, exc);
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);
Py_DECREF(cb); Py_DECREF(cb);
return r; return r;
} }

View File

@ -763,7 +763,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
_PyObject_ASSERT(op, callback != NULL); _PyObject_ASSERT(op, callback != NULL);
/* copy-paste of weakrefobject.c's handle_callback() */ /* copy-paste of weakrefobject.c's handle_callback() */
temp = PyObject_CallFunctionObjArgs(callback, wr, NULL); temp = _PyObject_CallOneArg(callback, (PyObject *)wr);
if (temp == NULL) if (temp == NULL)
PyErr_WriteUnraisable(callback); PyErr_WriteUnraisable(callback);
else else

View File

@ -134,7 +134,7 @@ groupby_step(groupbyobject *gbo)
newkey = newvalue; newkey = newvalue;
Py_INCREF(newvalue); Py_INCREF(newvalue);
} else { } else {
newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL); newkey = _PyObject_CallOneArg(gbo->keyfunc, newvalue);
if (newkey == NULL) { if (newkey == NULL) {
Py_DECREF(newvalue); Py_DECREF(newvalue);
return -1; return -1;
@ -1210,7 +1210,7 @@ dropwhile_next(dropwhileobject *lz)
if (lz->start == 1) if (lz->start == 1)
return item; return item;
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); good = _PyObject_CallOneArg(lz->func, item);
if (good == NULL) { if (good == NULL) {
Py_DECREF(item); Py_DECREF(item);
return NULL; return NULL;
@ -1373,7 +1373,7 @@ takewhile_next(takewhileobject *lz)
if (item == NULL) if (item == NULL)
return NULL; return NULL;
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); good = _PyObject_CallOneArg(lz->func, item);
if (good == NULL) { if (good == NULL) {
Py_DECREF(item); Py_DECREF(item);
return NULL; return NULL;
@ -3906,7 +3906,7 @@ filterfalse_next(filterfalseobject *lz)
ok = PyObject_IsTrue(item); ok = PyObject_IsTrue(item);
} else { } else {
PyObject *good; PyObject *good;
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); good = _PyObject_CallOneArg(lz->func, item);
if (good == NULL) { if (good == NULL) {
Py_DECREF(item); Py_DECREF(item);
return NULL; return NULL;

View File

@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code)
XML_ErrorString(code), lineno, column); XML_ErrorString(code), lineno, column);
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
err = PyObject_CallFunctionObjArgs(ErrorObject, buffer, NULL); err = _PyObject_CallOneArg(ErrorObject, buffer);
Py_DECREF(buffer); Py_DECREF(buffer);
if ( err != NULL if ( err != NULL
&& set_error_attr(err, "code", code) && set_error_attr(err, "code", code)

View File

@ -172,13 +172,13 @@ PyObject_GetItem(PyObject *o, PyObject *key)
} }
if (PyType_Check(o)) { if (PyType_Check(o)) {
PyObject *meth, *result, *stack[1] = {key}; PyObject *meth, *result;
_Py_IDENTIFIER(__class_getitem__); _Py_IDENTIFIER(__class_getitem__);
if (_PyObject_LookupAttrId(o, &PyId___class_getitem__, &meth) < 0) { if (_PyObject_LookupAttrId(o, &PyId___class_getitem__, &meth) < 0) {
return NULL; return NULL;
} }
if (meth) { if (meth) {
result = _PyObject_FastCall(meth, stack, 1); result = _PyObject_CallOneArg(meth, key);
Py_DECREF(meth); Py_DECREF(meth);
return result; return result;
} }
@ -737,7 +737,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
} }
/* And call it. */ /* And call it. */
result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL); result = _PyObject_CallOneArg(meth, format_spec);
Py_DECREF(meth); Py_DECREF(meth);
if (result && !PyUnicode_Check(result)) { if (result && !PyUnicode_Check(result)) {
@ -2459,7 +2459,7 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls)
Py_DECREF(checker); Py_DECREF(checker);
return ok; return ok;
} }
res = PyObject_CallFunctionObjArgs(checker, inst, NULL); res = _PyObject_CallOneArg(checker, inst);
Py_LeaveRecursiveCall(); Py_LeaveRecursiveCall();
Py_DECREF(checker); Py_DECREF(checker);
if (res != NULL) { if (res != NULL) {
@ -2533,7 +2533,7 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls)
Py_DECREF(checker); Py_DECREF(checker);
return ok; return ok;
} }
res = PyObject_CallFunctionObjArgs(checker, derived, NULL); res = _PyObject_CallOneArg(checker, derived);
Py_LeaveRecursiveCall(); Py_LeaveRecursiveCall();
Py_DECREF(checker); Py_DECREF(checker);
if (res != NULL) { if (res != NULL) {

View File

@ -89,8 +89,7 @@ _canresize(PyByteArrayObject *self)
PyObject * PyObject *
PyByteArray_FromObject(PyObject *input) PyByteArray_FromObject(PyObject *input)
{ {
return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type, return _PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input);
input, NULL);
} }
static PyObject * static PyObject *
@ -2018,8 +2017,7 @@ bytearray_fromhex_impl(PyTypeObject *type, PyObject *string)
{ {
PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type); PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type);
if (type != &PyByteArray_Type && result != NULL) { if (type != &PyByteArray_Type && result != NULL) {
Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result));
result, NULL));
} }
return result; return result;
} }

View File

@ -2333,8 +2333,7 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
{ {
PyObject *result = _PyBytes_FromHex(string, 0); PyObject *result = _PyBytes_FromHex(string, 0);
if (type != &PyBytes_Type && result != NULL) { if (type != &PyBytes_Type && result != NULL) {
Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result));
result, NULL));
} }
return result; return result;
} }

View File

@ -1340,8 +1340,7 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL; return NULL;
} }
PyObject *args[1] = {obj}; return _PyObject_CallOneArg(gs->prop_get, obj);
return _PyObject_FastCall(gs->prop_get, args, 1);
} }
static int static int
@ -1362,7 +1361,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
return -1; return -1;
} }
if (value == NULL) if (value == NULL)
res = PyObject_CallFunctionObjArgs(func, obj, NULL); res = _PyObject_CallOneArg(func, obj);
else else
res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
if (res == NULL) if (res == NULL)

View File

@ -2113,8 +2113,7 @@ dict_subscript(PyDictObject *mp, PyObject *key)
_Py_IDENTIFIER(__missing__); _Py_IDENTIFIER(__missing__);
missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__); missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__);
if (missing != NULL) { if (missing != NULL) {
res = PyObject_CallFunctionObjArgs(missing, res = _PyObject_CallOneArg(missing, key);
key, NULL);
Py_DECREF(missing); Py_DECREF(missing);
return res; return res;
} }

View File

@ -136,7 +136,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
Py_DECREF(writer); Py_DECREF(writer);
return -1; return -1;
} }
result = PyObject_CallFunctionObjArgs(writer, value, NULL); result = _PyObject_CallOneArg(writer, value);
Py_DECREF(value); Py_DECREF(value);
Py_DECREF(writer); Py_DECREF(writer);
if (result == NULL) if (result == NULL)

View File

@ -1501,7 +1501,7 @@ float_fromhex(PyTypeObject *type, PyObject *string)
goto parse_error; goto parse_error;
result = PyFloat_FromDouble(negate ? -x : x); result = PyFloat_FromDouble(negate ? -x : x);
if (type != &PyFloat_Type && result != NULL) { 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; return result;

View File

@ -57,7 +57,7 @@ _PyGen_Finalize(PyObject *self)
/* Save the current exception, if any. */ /* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback); PyErr_Fetch(&error_type, &error_value, &error_traceback);
res = PyObject_CallFunctionObjArgs(finalizer, self, NULL); res = _PyObject_CallOneArg(finalizer, self);
if (res == NULL) { if (res == NULL) {
PyErr_WriteUnraisable(self); PyErr_WriteUnraisable(self);
@ -562,7 +562,7 @@ _PyGen_SetStopIterationValue(PyObject *value)
return 0; return 0;
} }
/* Construct an exception instance manually with /* 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 * We do this to handle a situation when "value" is a tuple, in which
* case PyErr_SetObject would set the value of StopIteration to * 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.) * (See PyErr_SetObject/_PyErr_CreateException code for details.)
*/ */
e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL); e = _PyObject_CallOneArg(PyExc_StopIteration, value);
if (e == NULL) { if (e == NULL) {
return -1; return -1;
} }
@ -1279,7 +1279,7 @@ async_gen_init_hooks(PyAsyncGenObject *o)
PyObject *res; PyObject *res;
Py_INCREF(firstiter); Py_INCREF(firstiter);
res = PyObject_CallFunctionObjArgs(firstiter, o, NULL); res = _PyObject_CallOneArg(firstiter, (PyObject *)o);
Py_DECREF(firstiter); Py_DECREF(firstiter);
if (res == NULL) { if (res == NULL) {
return 1; return 1;

View File

@ -2258,8 +2258,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
} }
for (i = 0; i < saved_ob_size ; i++) { for (i = 0; i < saved_ob_size ; i++) {
keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i], keys[i] = _PyObject_CallOneArg(keyfunc, saved_ob_item[i]);
NULL);
if (keys[i] == NULL) { if (keys[i] == NULL) {
for (i=i-1 ; i>=0 ; i--) for (i=i-1 ; i>=0 ; i--)
Py_DECREF(keys[i]); Py_DECREF(keys[i]);

View File

@ -5611,8 +5611,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj,
Py_DECREF(bytes); Py_DECREF(bytes);
if (long_obj != NULL && type != &PyLong_Type) { if (long_obj != NULL && type != &PyLong_Type) {
Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type, Py_SETREF(long_obj, _PyObject_CallOneArg((PyObject *)type, long_obj));
long_obj, NULL));
} }
return long_obj; return long_obj;

View File

@ -1962,7 +1962,7 @@ struct_get_unpacker(const char *fmt, Py_ssize_t itemsize)
if (format == NULL) if (format == NULL)
goto error; goto error;
structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL); structobj = _PyObject_CallOneArg(Struct, format);
if (structobj == NULL) if (structobj == NULL)
goto error; goto error;
@ -2001,7 +2001,7 @@ struct_unpack_single(const char *ptr, struct unpacker *x)
PyObject *v; PyObject *v;
memcpy(x->item, ptr, x->itemsize); 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) if (v == NULL)
return NULL; return NULL;

View File

@ -736,8 +736,7 @@ module_getattro(PyModuleObject *m, PyObject *name)
_Py_IDENTIFIER(__getattr__); _Py_IDENTIFIER(__getattr__);
getattr = _PyDict_GetItemId(m->md_dict, &PyId___getattr__); getattr = _PyDict_GetItemId(m->md_dict, &PyId___getattr__);
if (getattr) { if (getattr) {
PyObject* stack[1] = {name}; return _PyObject_CallOneArg(getattr, name);
return _PyObject_FastCall(getattr, stack, 1);
} }
_Py_IDENTIFIER(__name__); _Py_IDENTIFIER(__name__);
mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__);

View File

@ -1459,8 +1459,7 @@ static PyObject*
call_unbound_noarg(int unbound, PyObject *func, PyObject *self) call_unbound_noarg(int unbound, PyObject *func, PyObject *self)
{ {
if (unbound) { if (unbound) {
PyObject *args[1] = {self}; return _PyObject_CallOneArg(func, self);
return _PyObject_FastCall(func, args, 1);
} }
else { else {
return _PyObject_CallNoArg(func); return _PyObject_CallNoArg(func);
@ -6561,7 +6560,7 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name)
else else
attr = descr; attr = descr;
} }
res = PyObject_CallFunctionObjArgs(attr, name, NULL); res = _PyObject_CallOneArg(attr, name);
Py_XDECREF(descr); Py_XDECREF(descr);
return res; return res;
} }

View File

@ -4248,7 +4248,7 @@ unicode_decode_call_errorhandler_wchar(
if (*exceptionObject == NULL) if (*exceptionObject == NULL)
goto onError; goto onError;
restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject);
if (restuple == NULL) if (restuple == NULL)
goto onError; goto onError;
if (!PyTuple_Check(restuple)) { if (!PyTuple_Check(restuple)) {
@ -4352,7 +4352,7 @@ unicode_decode_call_errorhandler_writer(
if (*exceptionObject == NULL) if (*exceptionObject == NULL)
goto onError; goto onError;
restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject);
if (restuple == NULL) if (restuple == NULL)
goto onError; goto onError;
if (!PyTuple_Check(restuple)) { if (!PyTuple_Check(restuple)) {
@ -6799,8 +6799,7 @@ unicode_encode_call_errorhandler(const char *errors,
if (*exceptionObject == NULL) if (*exceptionObject == NULL)
return NULL; return NULL;
restuple = PyObject_CallFunctionObjArgs( restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject);
*errorHandler, *exceptionObject, NULL);
if (restuple == NULL) if (restuple == NULL)
return NULL; return NULL;
if (!PyTuple_Check(restuple)) { if (!PyTuple_Check(restuple)) {
@ -8778,8 +8777,7 @@ unicode_translate_call_errorhandler(const char *errors,
if (*exceptionObject == NULL) if (*exceptionObject == NULL)
return NULL; return NULL;
restuple = PyObject_CallFunctionObjArgs( restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject);
*errorHandler, *exceptionObject, NULL);
if (restuple == NULL) if (restuple == NULL)
return NULL; return NULL;
if (!PyTuple_Check(restuple)) { if (!PyTuple_Check(restuple)) {

View File

@ -874,7 +874,7 @@ PyWeakref_GetObject(PyObject *ref)
static void static void
handle_callback(PyWeakReference *ref, PyObject *callback) handle_callback(PyWeakReference *ref, PyObject *callback)
{ {
PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); PyObject *cbresult = _PyObject_CallOneArg(callback, (PyObject *)ref);
if (cbresult == NULL) if (cbresult == NULL)
PyErr_WriteUnraisable(callback); PyErr_WriteUnraisable(callback);

View File

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

View File

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

View File

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

View File

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

View File

@ -93,7 +93,7 @@ _PyErr_CreateException(PyObject *exception, PyObject *value)
return PyObject_Call(exception, value, NULL); return PyObject_Call(exception, value, NULL);
} }
else { 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, hook_args = make_unraisable_hook_args(tstate, exc_type, exc_value,
exc_tb, err_msg, obj); exc_tb, err_msg, obj);
if (hook_args != NULL) { if (hook_args != NULL) {
PyObject *args[1] = {hook_args}; PyObject *res = _PyObject_CallOneArg(hook, hook_args);
PyObject *res = _PyObject_FastCall(hook, args, 1);
Py_DECREF(hook_args); Py_DECREF(hook_args);
if (res != NULL) { if (res != NULL) {
Py_DECREF(res); 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); PyObject *hook = PyList_GetItem(path_hooks, j);
if (hook == NULL) if (hook == NULL)
return NULL; return NULL;
importer = PyObject_CallFunctionObjArgs(hook, p, NULL); importer = _PyObject_CallOneArg(hook, p);
if (importer != NULL) if (importer != NULL)
break; break;