mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
* 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:
parent
27922eef35
commit
7c2bb5bc57
2 changed files with 79 additions and 15 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue