Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 20717:84715d52d954 legacy-trunk
vgetargskeywords: The keywords arg is a dict (if non-NULL), so use the
dict API everywhere on it instead of sometimes using the slower mapping
API.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Sat, 27 Oct 2001 05:50:39 +0000 |
| parents | dcf769c12d8b |
| children | c6384591d846 |
line wrap: on
line diff
--- a/Python/getargs.c Sat Oct 27 05:30:17 2001 +0000 +++ b/Python/getargs.c Sat Oct 27 05:50:39 2001 +0000 @@ -1090,7 +1090,7 @@ char *thiskw = kwlist[i]; if (thiskw == NULL) break; - if (PyMapping_HasKeyString(keywords, thiskw)) { + if (PyDict_GetItemString(keywords, thiskw)) { PyErr_Format(PyExc_TypeError, "keyword parameter '%s' was given " "by position and by name", @@ -1105,9 +1105,8 @@ len = nargs; if (keywords && nargs < min) { for (i = nargs; i < min; i++) { - if (PyMapping_HasKeyString(keywords, kwlist[i])) { + if (PyDict_GetItemString(keywords, kwlist[i])) len++; - } } } PyErr_Clear(); @@ -1168,15 +1167,16 @@ PyObject *item; if (*format == '|') format++; - item = PyMapping_GetItemString(keywords, kwlist[i]); + item = PyDict_GetItemString(keywords, kwlist[i]); if (item != NULL) { + Py_INCREF(item); msg = convertitem(item, &format, p_va, levels, msgbuf); + Py_DECREF(item); if (msg) { seterror(i+1, msg, levels, fname, message); return 0; } converted++; - Py_DECREF(item); } else { PyErr_Clear();
