Modified itertools.izip() to match the behavior of __builtin__.zip()

which can now take zero arguments.
This commit is contained in:
Raymond Hettinger 2003-08-08 05:10:41 +00:00
parent 77fe69bd08
commit b5a420883c
4 changed files with 15 additions and 8 deletions

View file

@ -1510,12 +1510,6 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *result;
int tuplesize = PySequence_Length(args);
if (tuplesize < 1) {
PyErr_SetString(PyExc_TypeError,
"izip() requires at least one sequence");
return NULL;
}
/* args must be a tuple */
assert(PyTuple_Check(args));
@ -1598,6 +1592,8 @@ izip_next(izipobject *lz)
PyObject *it;
PyObject *item;
if (tuplesize == 0)
return NULL;
if (result->ob_refcnt == 1) {
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);