bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267)
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index c9a8a07..e9a2319 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -156,6 +156,13 @@
PyObject *name, PyObject *const *args,
size_t nargsf, PyObject *kwnames);
+static inline PyObject *
+_PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
+{
+ return _PyObject_VectorcallMethod(name, &self,
+ 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
@@ -184,6 +191,13 @@
return _PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
}
+static inline PyObject *
+_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
+{
+ return _PyObject_VectorcallMethodId(name, &self,
+ 1 | 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__().