* 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.
This commit is contained in:
Raymond Hettinger 2003-05-03 05:59:48 +00:00
parent 27922eef35
commit 7c2bb5bc57
2 changed files with 79 additions and 15 deletions

View file

@ -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;