From: Raymond Hettinger Date: Sun, 11 Jan 2004 23:26:51 +0000 (+0000) Subject: SF Patch #871704: Py_SequenceFast can mask errors X-Git-Tag: v2.4a1~948 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2fb702966c9c7e29c2697cf0d9dc6b1a19e465d7;p=thirdparty%2FPython%2Fcpython.git SF Patch #871704: Py_SequenceFast can mask errors (Contributed by Greg Chapman.) Since this only changes the error message, I doubt that it should be backported. --- diff --git a/Objects/abstract.c b/Objects/abstract.c index 342d9718798c..4ac92608ab91 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; }