summaryrefslogtreecommitdiff
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-17 03:02:14 +0000
committerRaymond Hettinger <python@rcn.com>2008-01-17 03:02:14 +0000
commitf660ee7d2f3a7c37f68b47e5135dda81be383701 (patch)
tree0199de7b76e04d82e45ddd02bd9cfbf8d4df20c0 /Modules/itertoolsmodule.c
parent99739f54cfbf8f9b66949841c9fdee5b7bcb0355 (diff)
downloadcpython-f660ee7d2f3a7c37f68b47e5135dda81be383701.tar.gz
Make starmap() match its pure python definition and accept any itertable input (not just tuples).
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r--Modules/itertoolsmodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index ebb4deb268..430313eaa6 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1356,10 +1356,11 @@ starmap_next(starmapobject *lz)
if (args == NULL)
return NULL;
if (!PyTuple_CheckExact(args)) {
+ PyObject *newargs = PySequence_Tuple(args);
Py_DECREF(args);
- PyErr_SetString(PyExc_TypeError,
- "iterator must return a tuple");
- return NULL;
+ if (newargs == NULL)
+ return NULL;
+ args = newargs;
}
result = PyObject_Call(lz->func, args, NULL);
Py_DECREF(args);