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,
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;
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);
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);
/* 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);
/* 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;
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;
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)