[Python-checkins] cpython: Cleanup _PyMethodDef_RawFastCallDict()
victor.stinner
python-checkins at python.org
Wed Jan 18 08:22:58 EST 2017
https://hg.python.org/cpython/rev/8cc5d78d9b18
changeset: 106220:8cc5d78d9b18
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Jan 18 14:16:57 2017 +0100
summary:
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.
files:
Objects/methodobject.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -93,6 +93,7 @@
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 @@
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:
{
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list