Commit 6fea7f7f authored by Victor Stinner's avatar Victor Stinner

Issue #27809: Cleanup _PyEval_EvalCodeWithName()

* Rename nm to name
* PEP 7: add { ... } to if/else blocks
parent b9009391
...@@ -3878,28 +3878,28 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals, ...@@ -3878,28 +3878,28 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
normally interned this should almost always hit. */ normally interned this should almost always hit. */
co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item; co_varnames = ((PyTupleObject *)(co->co_varnames))->ob_item;
for (j = 0; j < total_args; j++) { for (j = 0; j < total_args; j++) {
PyObject *nm = co_varnames[j]; PyObject *name = co_varnames[j];
if (nm == keyword) if (name == keyword) {
goto kw_found; goto kw_found;
}
} }
/* Slow fallback, just in case */ /* Slow fallback, just in case */
for (j = 0; j < total_args; j++) { for (j = 0; j < total_args; j++) {
PyObject *nm = co_varnames[j]; PyObject *name = co_varnames[j];
int cmp = PyObject_RichCompareBool( int cmp = PyObject_RichCompareBool( keyword, name, Py_EQ);
keyword, nm, Py_EQ); if (cmp > 0) {
if (cmp > 0)
goto kw_found; goto kw_found;
else if (cmp < 0) }
else if (cmp < 0) {
goto fail; goto fail;
}
} }
if (j >= total_args && kwdict == NULL) { if (j >= total_args && kwdict == NULL) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%U() got an unexpected " "%U() got an unexpected keyword argument '%S'",
"keyword argument '%S'", co->co_name, keyword);
co->co_name,
keyword);
goto fail; goto fail;
} }
...@@ -3911,10 +3911,8 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals, ...@@ -3911,10 +3911,8 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
kw_found: kw_found:
if (GETLOCAL(j) != NULL) { if (GETLOCAL(j) != NULL) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"%U() got multiple " "%U() got multiple values for argument '%S'",
"values for argument '%S'", co->co_name, keyword);
co->co_name,
keyword);
goto fail; goto fail;
} }
Py_INCREF(value); Py_INCREF(value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment