bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index 415f3e1..b4288e7 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -158,6 +158,10 @@
PyObject *args,
PyObject *kwargs);
+PyAPI_FUNC(PyObject *) _PyObject_VectorcallMethod(
+ PyObject *name, PyObject *const *args,
+ size_t nargsf, PyObject *kwnames);
+
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
@@ -174,6 +178,18 @@
struct _Py_Identifier *name,
...);
+static inline PyObject *
+_PyObject_VectorcallMethodId(
+ _Py_Identifier *name, PyObject *const *args,
+ size_t nargsf, PyObject *kwnames)
+{
+ PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
+ if (!oname) {
+ return NULL;
+ }
+ return _PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
+}
+
PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
/* Guess the size of object 'o' using len(o) or o.__length_hint__().