bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index e9a2319..d57aa54 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -163,6 +163,15 @@
1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
}
+static inline PyObject *
+_PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
+{
+ assert(arg != NULL);
+ PyObject *args[2] = {self, arg};
+ return _PyObject_VectorcallMethod(name, args,
+ 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
@@ -198,6 +207,15 @@
1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
}
+static inline PyObject *
+_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
+{
+ assert(arg != NULL);
+ PyObject *args[2] = {self, arg};
+ return _PyObject_VectorcallMethodId(name, args,
+ 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
/* Guess the size of object 'o' using len(o) or o.__length_hint__().