mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-20627: Fix error message when keyword arguments are used (#2115)
This commit is contained in:
parent
8acb4cf2b3
commit
96c7c06850
4 changed files with 48 additions and 14 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue