summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-08-26 06:42:30 (GMT)
committerGeorg Brandl <georg@python.org>2005-08-26 06:42:30 (GMT)
commit02c42871cf73365dc5b6915cac2b017b2b90c81f (patch)
treea85d3fb2fc3682c2a149d213f5cf9a378868abea /Modules
parentbd77da6dab9d41ef246febf54c7928ce4496dd49 (diff)
downloadcpython-02c42871cf73365dc5b6915cac2b017b2b90c81f.zip
cpython-02c42871cf73365dc5b6915cac2b017b2b90c81f.tar.gz
cpython-02c42871cf73365dc5b6915cac2b017b2b90c81f.tar.bz2
Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_randommodule.c3
-rw-r--r--Modules/arraymodule.c15
-rw-r--r--Modules/collectionsmodule.c3
-rw-r--r--Modules/itertoolsmodule.c36
-rw-r--r--Modules/operator.c6
-rw-r--r--Modules/zipimport.c3
6 files changed, 54 insertions, 12 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 1189036..8fe2b2b 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -481,6 +481,9 @@ random_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
RandomObject *self;
PyObject *tmp;
+ if (!_PyArg_NoKeywords("Random()", kwds))
+ return NULL;
+
self = (RandomObject *)type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 6430333..3c60350 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -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;
diff --git a/Modules/collectionsmodule.c b/Modules/collectionsmodule.c
index 2fbd729..ffe1a96 100644
--- a/Modules/collectionsmodule.c
+++ b/Modules/collectionsmodule.c
@@ -95,6 +95,9 @@ deque_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
dequeobject *deque;
block *b;
+ if (!_PyArg_NoKeywords("deque()", kwds))
+ return NULL;
+
/* create dequeobject structure */
deque = (dequeobject *)type->tp_alloc(type, 0);
if (deque == NULL)
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 31ba13a..34b37be 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -618,6 +618,9 @@ cycle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *saved;
cycleobject *lz;
+ if (!_PyArg_NoKeywords("cycle()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "cycle", 1, 1, &iterable))
return NULL;
@@ -765,6 +768,9 @@ dropwhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
dropwhileobject *lz;
+ if (!_PyArg_NoKeywords("dropwhile()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "dropwhile", 2, 2, &func, &seq))
return NULL;
@@ -906,6 +912,9 @@ takewhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
takewhileobject *lz;
+ if (!_PyArg_NoKeywords("takewhile()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "takewhile", 2, 2, &func, &seq))
return NULL;
@@ -1048,6 +1057,9 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int numargs;
isliceobject *lz;
+ if (!_PyArg_NoKeywords("islice()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "islice", 2, 4, &seq, &a1, &a2, &a3))
return NULL;
@@ -1236,6 +1248,9 @@ starmap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
starmapobject *lz;
+ if (!_PyArg_NoKeywords("starmap()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "starmap", 2, 2, &func, &seq))
return NULL;
@@ -1365,6 +1380,9 @@ imap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
imapobject *lz;
int numargs, i;
+ if (!_PyArg_NoKeywords("imap()", kwds))
+ return NULL;
+
numargs = PyTuple_Size(args);
if (numargs < 2) {
PyErr_SetString(PyExc_TypeError,
@@ -1544,6 +1562,9 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int i;
PyObject *ittuple;
+ if (!_PyArg_NoKeywords("chain()", kwds))
+ return NULL;
+
/* obtain iterators */
assert(PyTuple_Check(args));
ittuple = PyTuple_New(tuplesize);
@@ -1684,6 +1705,9 @@ ifilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
ifilterobject *lz;
+ if (!_PyArg_NoKeywords("ifilter()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "ifilter", 2, 2, &func, &seq))
return NULL;
@@ -1825,6 +1849,9 @@ ifilterfalse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
ifilterfalseobject *lz;
+ if (!_PyArg_NoKeywords("ifilterfalse()", kwds))
+ return NULL;
+
if (!PyArg_UnpackTuple(args, "ifilterfalse", 2, 2, &func, &seq))
return NULL;
@@ -1964,6 +1991,9 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
countobject *lz;
long cnt = 0;
+ if (!_PyArg_NoKeywords("count()", kwds))
+ return NULL;
+
if (!PyArg_ParseTuple(args, "|l:count", &cnt))
return NULL;
@@ -2060,6 +2090,9 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *result;
int tuplesize = PySequence_Length(args);
+ if (!_PyArg_NoKeywords("izip()", kwds))
+ return NULL;
+
/* args must be a tuple */
assert(PyTuple_Check(args));
@@ -2240,6 +2273,9 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *element;
long cnt = -1;
+ if (!_PyArg_NoKeywords("repeat()", kwds))
+ return NULL;
+
if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt))
return NULL;
diff --git a/Modules/operator.c b/Modules/operator.c
index 938c5e5..4e1e517 100644
--- a/Modules/operator.c
+++ b/Modules/operator.c
@@ -269,6 +269,9 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *item;
int nitems;
+ if (!_PyArg_NoKeywords("itemgetter()", kwds))
+ return NULL;
+
nitems = PyTuple_GET_SIZE(args);
if (nitems <= 1) {
if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &item))
@@ -405,6 +408,9 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *attr;
int nattrs;
+ if (!_PyArg_NoKeywords("attrgetter()", kwds))
+ return NULL;
+
nattrs = PyTuple_GET_SIZE(args);
if (nattrs <= 1) {
if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &attr))
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 9630dea..e445300 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -65,6 +65,9 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
char *path, *p, *prefix, buf[MAXPATHLEN+2];
int len;
+ if (!_PyArg_NoKeywords("zipimporter()", kwds))
+ return -1;
+
if (!PyArg_ParseTuple(args, "s:zipimporter",
&path))
return -1;