Make starmap() match its pure python definition and accept any itertable input (not just tuples).
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index ebb4deb..430313e 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1356,10 +1356,11 @@
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);