bpo-20627: Fix error message when keyword arguments are used (#2115)

This commit is contained in:
Sylvain 2017-06-15 17:05:23 +02:00 committed by Serhiy Storchaka
parent 8acb4cf2b3
commit 96c7c06850
4 changed files with 48 additions and 14 deletions

View file

@ -997,13 +997,13 @@ builtin_getattr(PyObject *self, PyObject **args, Py_ssize_t nargs,
PyObject *v, *result, *dflt = NULL;
PyObject *name;
if (!_PyArg_UnpackStack(args, nargs, "getattr", 2, 3, &v, &name, &dflt))
return NULL;
if (!_PyArg_NoStackKeywords("getattr", kwnames)) {
return NULL;
}
if (!_PyArg_UnpackStack(args, nargs, "getattr", 2, 3, &v, &name, &dflt))
return NULL;
if (!PyUnicode_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"getattr(): attribute name must be string");
@ -1307,13 +1307,13 @@ builtin_next(PyObject *self, PyObject **args, Py_ssize_t nargs,
PyObject *it, *res;
PyObject *def = NULL;
if (!_PyArg_UnpackStack(args, nargs, "next", 1, 2, &it, &def))
return NULL;
if (!_PyArg_NoStackKeywords("next", kwnames)) {
return NULL;
}
if (!_PyArg_UnpackStack(args, nargs, "next", 1, 2, &it, &def))
return NULL;
if (!PyIter_Check(it)) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not an iterator",