diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-01-18 13:16:57 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-01-18 13:16:57 (GMT) |
commit | 0a2e46835dbadc626a996c2d937f5b45123ca6de (patch) | |
tree | ee2035a292ab8b2a4c9be7dc7a2b8b337a3e5469 /Objects/methodobject.c | |
parent | a8cb515a297989b731f2520f5518dde653de24ee (diff) | |
download | cpython-0a2e46835dbadc626a996c2d937f5b45123ca6de.zip cpython-0a2e46835dbadc626a996c2d937f5b45123ca6de.tar.gz cpython-0a2e46835dbadc626a996c2d937f5b45123ca6de.tar.bz2 |
Cleanup _PyMethodDef_RawFastCallDict()
Issue #29259: use a different case for METH_VARARGS and
METH_VARARGS|METH_KEYWORDS to avoid testing again flags to decide if keywords
should be checked or not.
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r-- | Objects/methodobject.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c index ebea8b3..35a827e 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -93,6 +93,7 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg PyCFunction meth; PyObject *result; int flags; + PyObject *argstuple; /* _PyMethodDef_RawFastCallDict() must not be called with an exception set, because it can clear it (directly or indirectly) and so the @@ -140,30 +141,27 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg break; case METH_VARARGS: - case METH_VARARGS | METH_KEYWORDS: - { - /* Slow-path: create a temporary tuple for positional arguments */ - PyObject *tuple; - if (!(flags & METH_KEYWORDS) && kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) { goto no_keyword_error; } + /* fall through next case */ - tuple = _PyStack_AsTuple(args, nargs); - if (tuple == NULL) { + case METH_VARARGS | METH_KEYWORDS: + /* Slow-path: create a temporary tuple for positional arguments */ + argstuple = _PyStack_AsTuple(args, nargs); + if (argstuple == NULL) { return NULL; } if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)meth) (self, tuple, kwargs); + result = (*(PyCFunctionWithKeywords)meth) (self, argstuple, kwargs); } else { - result = (*meth) (self, tuple); + result = (*meth) (self, argstuple); } - Py_DECREF(tuple); + Py_DECREF(argstuple); break; - } case METH_FASTCALL: { |