mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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.
This commit is contained in:
parent
61dde63e3b
commit
077f574db1
1 changed files with 5 additions and 5 deletions
|
@ -1090,7 +1090,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
|
||||||
char *thiskw = kwlist[i];
|
char *thiskw = kwlist[i];
|
||||||
if (thiskw == NULL)
|
if (thiskw == NULL)
|
||||||
break;
|
break;
|
||||||
if (PyMapping_HasKeyString(keywords, thiskw)) {
|
if (PyDict_GetItemString(keywords, thiskw)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"keyword parameter '%s' was given "
|
"keyword parameter '%s' was given "
|
||||||
"by position and by name",
|
"by position and by name",
|
||||||
|
@ -1105,9 +1105,8 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
|
||||||
len = nargs;
|
len = nargs;
|
||||||
if (keywords && nargs < min) {
|
if (keywords && nargs < min) {
|
||||||
for (i = nargs; i < min; i++) {
|
for (i = nargs; i < min; i++) {
|
||||||
if (PyMapping_HasKeyString(keywords, kwlist[i])) {
|
if (PyDict_GetItemString(keywords, kwlist[i]))
|
||||||
len++;
|
len++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
@ -1168,15 +1167,16 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
if (*format == '|')
|
if (*format == '|')
|
||||||
format++;
|
format++;
|
||||||
item = PyMapping_GetItemString(keywords, kwlist[i]);
|
item = PyDict_GetItemString(keywords, kwlist[i]);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
|
Py_INCREF(item);
|
||||||
msg = convertitem(item, &format, p_va, levels, msgbuf);
|
msg = convertitem(item, &format, p_va, levels, msgbuf);
|
||||||
|
Py_DECREF(item);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
seterror(i+1, msg, levels, fname, message);
|
seterror(i+1, msg, levels, fname, message);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
converted++;
|
converted++;
|
||||||
Py_DECREF(item);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue