mirror of https://github.com/python/cpython
cleanup a bit
This commit is contained in:
parent
a567a7796b
commit
232ecb8918
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue