diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-07-03 18:20:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 18:20:15 (GMT) |
commit | 6969eaf4682beb01bc95eeb14f5ce6c01312e297 (patch) | |
tree | c81a3d9bca3e9d01f557c46a8534a4e3873403f9 /Objects/call.c | |
parent | aa0aa0492c5fffe750a26d2ab13737a1a6d7d63c (diff) | |
download | cpython-6969eaf4682beb01bc95eeb14f5ce6c01312e297.zip cpython-6969eaf4682beb01bc95eeb14f5ce6c01312e297.tar.gz cpython-6969eaf4682beb01bc95eeb14f5ce6c01312e297.tar.bz2 |
bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)
the bare METH_FASTCALL be used for functions with positional-only
parameters.
Diffstat (limited to 'Objects/call.c')
-rw-r--r-- | Objects/call.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Objects/call.c b/Objects/call.c index 6c8a640..c3cc31d 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -521,9 +521,19 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg case METH_FASTCALL: { + if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) { + goto no_keyword_error; + } + + result = (*(_PyCFunctionFast)meth) (self, args, nargs); + break; + } + + case METH_FASTCALL | METH_KEYWORDS: + { PyObject **stack; PyObject *kwnames; - _PyCFunctionFast fastmeth = (_PyCFunctionFast)meth; + _PyCFunctionFastWithKeywords fastmeth = (_PyCFunctionFastWithKeywords)meth; if (_PyStack_UnpackDict(args, nargs, kwargs, &stack, &kwnames) < 0) { goto exit; @@ -631,8 +641,15 @@ _PyMethodDef_RawFastCallKeywords(PyMethodDef *method, PyObject *self, PyObject * break; case METH_FASTCALL: + if (nkwargs) { + goto no_keyword_error; + } + result = ((_PyCFunctionFast)meth) (self, args, nargs); + break; + + case METH_FASTCALL | METH_KEYWORDS: /* Fast-path: avoid temporary dict to pass keyword arguments */ - result = ((_PyCFunctionFast)meth) (self, args, nargs, kwnames); + result = ((_PyCFunctionFastWithKeywords)meth) (self, args, nargs, kwnames); break; case METH_VARARGS: |