diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-07-04 10:31:34 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-07-04 10:31:34 (GMT) |
commit | 196a530e00d88a138973bf9182e013937e293f97 (patch) | |
tree | 35443abb5aa148b459f68ae43a18cdbb0627ba76 /Include/cpython/abstract.h | |
parent | 9d40554e0da09a44a8547f3f3a2b9dedfeaf7928 (diff) | |
download | cpython-196a530e00d88a138973bf9182e013937e293f97.zip cpython-196a530e00d88a138973bf9182e013937e293f97.tar.gz cpython-196a530e00d88a138973bf9182e013937e293f97.tar.bz2 |
bpo-37483: add _PyObject_CallOneArg() function (#14558)
Diffstat (limited to 'Include/cpython/abstract.h')
-rw-r--r-- | Include/cpython/abstract.h | 12 |
1 files changed, 12 insertions, 0 deletions
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 @@ PyVectorcall_NARGS(size_t n) 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 @@ _PyObject_CallNoArg(PyObject *func) { 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, |