diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-05-29 18:31:52 (GMT) |
---|---|---|
committer | Petr Viktorin <encukou@gmail.com> | 2019-05-29 18:31:52 (GMT) |
commit | aacc77fbd77640a8f03638216fa09372cc21673d (patch) | |
tree | fd64be1c4c1167a8bf708d1fd22c733cf3a9a30f /Modules | |
parent | d30da5dd9a8a965cf24a22bbaff8a5b1341c2944 (diff) | |
download | cpython-aacc77fbd77640a8f03638216fa09372cc21673d.zip cpython-aacc77fbd77640a8f03638216fa09372cc21673d.tar.gz cpython-aacc77fbd77640a8f03638216fa09372cc21673d.tar.bz2 |
bpo-36974: implement PEP 590 (GH-13185)
Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_asynciomodule.c | 6 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 31 |
2 files changed, 30 insertions, 7 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index ac15d01..6013608 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -367,8 +367,7 @@ call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyObject *ctx) } stack[nargs] = (PyObject *)ctx; - handle = _PyObject_FastCallKeywords( - callable, stack, nargs, context_kwname); + handle = _PyObject_Vectorcall(callable, stack, nargs, context_kwname); Py_DECREF(callable); } @@ -2805,8 +2804,7 @@ set_exception: PyObject *stack[2]; stack[0] = wrapper; stack[1] = (PyObject *)task->task_context; - res = _PyObject_FastCallKeywords( - add_cb, stack, 1, context_kwname); + res = _PyObject_Vectorcall(add_cb, stack, 1, context_kwname); Py_DECREF(add_cb); Py_DECREF(wrapper); if (res == NULL) { diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 8ba9270..f2f418c 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4713,7 +4713,7 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args) static PyObject * -test_pyobject_fastcallkeywords(PyObject *self, PyObject *args) +test_pyobject_vectorcall(PyObject *self, PyObject *args) { PyObject *func, *func_args, *kwnames = NULL; PyObject **stack; @@ -4742,7 +4742,31 @@ test_pyobject_fastcallkeywords(PyObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "kwnames must be None or a tuple"); return NULL; } - return _PyObject_FastCallKeywords(func, stack, nargs, kwnames); + return _PyObject_Vectorcall(func, stack, nargs, kwnames); +} + + +static PyObject * +test_pyvectorcall_call(PyObject *self, PyObject *args) +{ + PyObject *func; + PyObject *argstuple; + PyObject *kwargs = NULL; + + if (!PyArg_ParseTuple(args, "OO|O", &func, &argstuple, &kwargs)) { + return NULL; + } + + if (!PyTuple_Check(argstuple)) { + PyErr_SetString(PyExc_TypeError, "args must be a tuple"); + return NULL; + } + if (kwargs != NULL && !PyDict_Check(kwargs)) { + PyErr_SetString(PyExc_TypeError, "kwargs must be a dict"); + return NULL; + } + + return PyVectorcall_Call(func, argstuple, kwargs); } @@ -5230,7 +5254,8 @@ static PyMethodDef TestMethods[] = { {"raise_SIGINT_then_send_None", raise_SIGINT_then_send_None, METH_VARARGS}, {"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS}, {"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS}, - {"pyobject_fastcallkeywords", test_pyobject_fastcallkeywords, METH_VARARGS}, + {"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS}, + {"pyvectorcall_call", test_pyvectorcall_call, METH_VARARGS}, {"stack_pointer", stack_pointer, METH_NOARGS}, #ifdef W_STOPCODE {"W_STOPCODE", py_w_stopcode, METH_VARARGS}, |