mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Bug #1550714: fix SystemError from itertools.tee on negative value for n.
Needs backport to 2.5.1 and earlier.
This commit is contained in:
parent
6aefa916a9
commit
69e8897505
3 changed files with 9 additions and 2 deletions
|
@ -618,11 +618,15 @@ static PyTypeObject tee_type = {
|
|||
static PyObject *
|
||||
tee(PyObject *self, PyObject *args)
|
||||
{
|
||||
int i, n=2;
|
||||
Py_ssize_t i, n=2;
|
||||
PyObject *it, *iterable, *copyable, *result;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|i", &iterable, &n))
|
||||
if (!PyArg_ParseTuple(args, "O|n", &iterable, &n))
|
||||
return NULL;
|
||||
if (n < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "n must be >= 0");
|
||||
return NULL;
|
||||
}
|
||||
result = PyTuple_New(n);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue