mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)
This commit is contained in:
parent
bd77da6dab
commit
02c42871cf
13 changed files with 100 additions and 13 deletions
|
@ -1799,18 +1799,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
char c;
|
||||
PyObject *initial = NULL, *it = NULL;
|
||||
struct arraydescr *descr;
|
||||
|
||||
if (kwds != NULL) {
|
||||
int i = PyObject_Length(kwds);
|
||||
if (i < 0)
|
||||
return NULL;
|
||||
else if (i > 0) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"array.array constructor takes "
|
||||
"no keyword arguments");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_PyArg_NoKeywords("array.array()", kwds))
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "c|O:array", &c, &initial))
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue