diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-03-21 21:08:54 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-03-21 21:08:54 (GMT) |
commit | 232ecb8918d90b62e914f2ddfaa91e3d02fac9e8 (patch) | |
tree | e0702f73ffe8d7e6b2dbcbba9a060d366da53025 /Python | |
parent | a567a7796ba5207fbec5b44c4df004378b7db802 (diff) | |
download | cpython-232ecb8918d90b62e914f2ddfaa91e3d02fac9e8.zip cpython-232ecb8918d90b62e914f2ddfaa91e3d02fac9e8.tar.gz cpython-232ecb8918d90b62e914f2ddfaa91e3d02fac9e8.tar.bz2 |
cleanup a bit
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index ae9ab47..9be0bd6 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3041,6 +3041,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, register PyObject **fastlocals, **freevars; PyThreadState *tstate = PyThreadState_GET(); PyObject *x, *u; + int total_args = co->co_argcount + co->co_kwonlyargcount; if (globals == NULL) { PyErr_SetString(PyExc_SystemError, @@ -3057,9 +3058,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, fastlocals = f->f_localsplus; freevars = f->f_localsplus + co->co_nlocals; - if (co->co_argcount > 0 || - co->co_kwonlyargcount > 0 || - co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { + if (total_args || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { int i; int n = argcount; PyObject *kwdict = NULL; @@ -3067,7 +3066,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, kwdict = PyDict_New(); if (kwdict == NULL) goto fail; - i = co->co_argcount + co->co_kwonlyargcount; + i = total_args; if (co->co_flags & CO_VARARGS) i++; SETLOCAL(i, kwdict); @@ -3095,7 +3094,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, u = PyTuple_New(argcount - n); if (u == NULL) goto fail; - SETLOCAL(co->co_argcount + co->co_kwonlyargcount, u); + SETLOCAL(total_args, u); for (i = n; i < argcount; i++) { x = args[i]; Py_INCREF(x); @@ -3116,17 +3115,13 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, /* Speed hack: do raw pointer compares. As names are normally interned this should almost always hit. */ co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item; - for (j = 0; - j < co->co_argcount + co->co_kwonlyargcount; - j++) { + for (j = 0; j < total_args; j++) { PyObject *nm = co_varnames[j]; if (nm == keyword) goto kw_found; } /* Slow fallback, just in case */ - for (j = 0; - j < co->co_argcount + co->co_kwonlyargcount; - j++) { + for (j = 0; j < total_args; j++) { PyObject *nm = co_varnames[j]; int cmp = PyObject_RichCompareBool( keyword, nm, Py_EQ); @@ -3138,15 +3133,13 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, /* Check errors from Compare */ if (PyErr_Occurred()) goto fail; - if (j >= co->co_argcount + co->co_kwonlyargcount) { - if (kwdict == NULL) { - PyErr_Format(PyExc_TypeError, - "%U() got an unexpected " - "keyword argument '%S'", - co->co_name, - keyword); - goto fail; - } + if (j >= total_args && kwdict == NULL) { + PyErr_Format(PyExc_TypeError, + "%U() got an unexpected " + "keyword argument '%S'", + co->co_name, + keyword); + goto fail; } PyDict_SetItem(kwdict, keyword, value); continue; @@ -3164,9 +3157,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, SETLOCAL(j, value); } if (co->co_kwonlyargcount > 0) { - for (i = co->co_argcount; - i < co->co_argcount + co->co_kwonlyargcount; - i++) { + for (i = co->co_argcount; i < total_args; i++) { PyObject *name, *def; if (GETLOCAL(i) != NULL) continue; @@ -3232,7 +3223,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, Py_UNICODE *cellname, *argname; PyObject *c; - nargs = co->co_argcount + co->co_kwonlyargcount; + nargs = total_args; if (co->co_flags & CO_VARARGS) nargs++; if (co->co_flags & CO_VARKEYWORDS) |