bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)

This commit is contained in:
Jeroen Demeyer 2019-07-11 10:59:05 +02:00 committed by Inada Naoki
parent 2a3d4d9c53
commit 59ad110d7a
23 changed files with 104 additions and 93 deletions

View file

@ -163,6 +163,15 @@ _PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
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 @@ _PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
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__().