.. 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
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;
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,
--- /dev/null
+Add new function ``_PyObject_CallOneArg`` for calling an object with one
+positional argument.
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;
}
_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 *
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);
}
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;
}
return NULL;
}
- res = PyObject_CallFunctionObjArgs(all_tasks_func, loop, NULL);
+ res = _PyObject_CallOneArg(all_tasks_func, loop);
Py_DECREF(all_tasks_func);
return res;
}
_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]
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);
}
return NULL;
}
- PyObject *e = PyObject_CallFunctionObjArgs(et, msg, NULL);
+ PyObject *e = _PyObject_CallOneArg(et, msg);
Py_DECREF(msg);
if (e == NULL) {
return NULL;
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);
if (line == NULL) {
return NULL;
}
- result = PyObject_CallFunctionObjArgs(self->write, line, NULL);
+ result = _PyObject_CallOneArg(self->write, line);
Py_DECREF(line);
return result;
}
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);
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;
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;
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;
}
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;
}
if (self->comment_factory) {
- comment = _PyObject_FastCall(self->comment_factory, &text, 1);
+ comment = _PyObject_CallOneArg(self->comment_factory, text);
if (!comment)
return NULL;
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;
(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);
/* 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;
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);
}
}
if (!prefix)
return;
- res = _PyObject_FastCall(self->handle_end_ns, &prefix, 1);
+ res = _PyObject_CallOneArg(self->handle_end_ns, prefix);
Py_DECREF(prefix);
}
if (!comment)
return;
- res = _PyObject_FastCall(self->handle_comment, &comment, 1);
+ res = _PyObject_CallOneArg(self->handle_comment, comment);
}
Py_XDECREF(res);
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. */
*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;
}
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;
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;
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",
return -1;
}
}
- newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL);
+ newobj = _PyObject_CallOneArg(s->defaultfn, obj);
if (newobj == NULL) {
Py_XDECREF(ident);
return -1;
{
PyObject *result;
- result = PyObject_CallFunctionObjArgs(func, obj, NULL);
+ result = _PyObject_CallOneArg(func, obj);
Py_DECREF(obj);
return result;
}
return PyObject_CallFunctionObjArgs(func, self, obj, NULL);
}
else {
- return PyObject_CallFunctionObjArgs(func, obj, NULL);
+ return _PyObject_CallOneArg(func, obj);
}
}
return -1;
}
}
- result = PyObject_CallFunctionObjArgs(self->write, payload, NULL);
+ result = _PyObject_CallOneArg(self->write, payload);
Py_XDECREF(mem);
if (result == NULL) {
return -1;
}
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;
}
* 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;
}
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;
}
}
+ /* 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) {
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)) {
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);
}
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;
}
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 {
Py_DECREF(key);
if (adapter) {
Py_INCREF(adapter);
- adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL);
+ adapted = _PyObject_CallOneArg(adapter, obj);
Py_DECREF(adapter);
return adapted;
}
return NULL;
}
if (adapter) {
- adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL);
+ adapted = _PyObject_CallOneArg(adapter, obj);
Py_DECREF(adapter);
if (adapted == Py_None) {
return NULL;
}
if (adapter) {
- adapted = PyObject_CallFunctionObjArgs(adapter, proto, NULL);
+ adapted = _PyObject_CallOneArg(adapter, proto);
Py_DECREF(adapter);
if (adapted == Py_None) {
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;
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);
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 */
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);
if (codecobj == NULL)
return NULL;
- r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL);
+ r = _PyObject_CallOneArg(cofunc, codecobj);
Py_DECREF(codecobj);
return r;
static PyObject *
call_error_callback(PyObject *errors, PyObject *exc)
{
- PyObject *args, *cb, *r;
+ PyObject *cb, *r;
const char *str;
assert(PyUnicode_Check(errors));
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;
}
_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
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;
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;
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;
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;
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)
}
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;
}
}
/* And call it. */
- result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL);
+ result = _PyObject_CallOneArg(meth, format_spec);
Py_DECREF(meth);
if (result && !PyUnicode_Check(result)) {
Py_DECREF(checker);
return ok;
}
- res = PyObject_CallFunctionObjArgs(checker, inst, NULL);
+ res = _PyObject_CallOneArg(checker, inst);
Py_LeaveRecursiveCall();
Py_DECREF(checker);
if (res != NULL) {
Py_DECREF(checker);
return ok;
}
- res = PyObject_CallFunctionObjArgs(checker, derived, NULL);
+ res = _PyObject_CallOneArg(checker, derived);
Py_LeaveRecursiveCall();
Py_DECREF(checker);
if (res != NULL) {
PyObject *
PyByteArray_FromObject(PyObject *input)
{
- return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type,
- input, NULL);
+ return _PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input);
}
static PyObject *
{
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;
}
{
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;
}
return NULL;
}
- PyObject *args[1] = {obj};
- return _PyObject_FastCall(gs->prop_get, args, 1);
+ return _PyObject_CallOneArg(gs->prop_get, obj);
}
static int
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)
_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;
}
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)
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;
/* 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);
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
*
* (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;
}
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;
}
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]);
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;
if (format == NULL)
goto error;
- structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
+ structobj = _PyObject_CallOneArg(Struct, format);
if (structobj == NULL)
goto error;
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;
_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__);
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);
else
attr = descr;
}
- res = PyObject_CallFunctionObjArgs(attr, name, NULL);
+ res = _PyObject_CallOneArg(attr, name);
Py_XDECREF(descr);
return res;
}
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)) {
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)) {
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)) {
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)) {
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);
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);
}
else {
text = message;
- message = PyObject_CallFunctionObjArgs(category, message, NULL);
+ message = _PyObject_CallOneArg(category, message);
if (message == NULL)
goto cleanup;
}
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) {
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;
{
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++) {
}
continue;
}
- new_base = _PyObject_FastCall(meth, stack, 1);
+ new_base = _PyObject_CallOneArg(meth, bases);
Py_DECREF(meth);
if (!new_base) {
goto error;
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;
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;
}
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;
}
Py_DECREF(value);
goto error;
}
- res = PyObject_CallFunctionObjArgs(hook, value, NULL);
+ res = _PyObject_CallOneArg(hook, value);
Py_DECREF(value);
if (res == NULL)
goto error;
PyObject *_PyCodec_Lookup(const char *encoding)
{
- PyObject *result, *args = NULL, *v;
+ PyObject *result, *v;
Py_ssize_t i, len;
if (encoding == NULL) {
}
/* 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;
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) {
Py_DECREF(result);
goto onError;
}
- Py_DECREF(args);
return result;
onError:
- Py_XDECREF(args);
return NULL;
}
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;
}
return PyObject_Call(exception, value, NULL);
}
else {
- return PyObject_CallFunctionObjArgs(exception, value, NULL);
+ return _PyObject_CallOneArg(exception, value);
}
}
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);
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;