diff options
author | Raymond Hettinger <python@rcn.com> | 2003-05-03 05:59:48 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-05-03 05:59:48 (GMT) |
commit | 7c2bb5bc5765491a80bdca43545c5f41481cbf08 (patch) | |
tree | 82d63def5bd79ffec3e65938630fd825943a549d /Modules/itertoolsmodule.c | |
parent | 27922eef358c4952ad06625338bcad1dd7174e44 (diff) | |
download | cpython-7c2bb5bc5765491a80bdca43545c5f41481cbf08.zip cpython-7c2bb5bc5765491a80bdca43545c5f41481cbf08.tar.gz cpython-7c2bb5bc5765491a80bdca43545c5f41481cbf08.tar.bz2 |
* Added a substantial number of edge case and argument tests for
the itertoolsmodule.
* Taught itertools.repeat(obj, n) to treat negative repeat counts as
zero. This behavior matches that for sequences and prevents
infinite loops.
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 2d496b5..b52f349 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -1691,6 +1691,9 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt)) return NULL; + if (PyTuple_Size(args) == 2 && cnt < 0) + cnt = 0; + ro = (repeatobject *)type->tp_alloc(type, 0); if (ro == NULL) return NULL; |