summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 342d971..4ac9260 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1496,6 +1496,8 @@ PySequence_List(PyObject *v)
PyObject *
PySequence_Fast(PyObject *v, const char *m)
{
+ PyObject *it;
+
if (v == NULL)
return null_error();
@@ -1504,9 +1506,15 @@ PySequence_Fast(PyObject *v, const char *m)
return v;
}
- v = PySequence_Tuple(v);
- if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError))
- return type_error(m);
+ it = PyObject_GetIter(v);
+ if (it == NULL) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError))
+ return type_error(m);
+ return NULL;
+ }
+
+ v = PySequence_Tuple(it);
+ Py_DECREF(it);
return v;
}