bpo-37483: add _PyObject_CallOneArg() function (#14558)
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 @@
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 @@
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,