From f660ee7d2f3a7c37f68b47e5135dda81be383701 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 17 Jan 2008 03:02:14 +0000 Subject: Make starmap() match its pure python definition and accept any itertable input (not just tuples). --- Modules/itertoolsmodule.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Modules/itertoolsmodule.c') 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); -- cgit v1.2.1