Kaydet (Commit) 2fb70296 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

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.
üst 44a98237
...@@ -1496,6 +1496,8 @@ PySequence_List(PyObject *v) ...@@ -1496,6 +1496,8 @@ PySequence_List(PyObject *v)
PyObject * PyObject *
PySequence_Fast(PyObject *v, const char *m) PySequence_Fast(PyObject *v, const char *m)
{ {
PyObject *it;
if (v == NULL) if (v == NULL)
return null_error(); return null_error();
...@@ -1504,9 +1506,15 @@ PySequence_Fast(PyObject *v, const char *m) ...@@ -1504,9 +1506,15 @@ PySequence_Fast(PyObject *v, const char *m)
return v; return v;
} }
v = PySequence_Tuple(v); it = PyObject_GetIter(v);
if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) if (it == NULL) {
return type_error(m); if (PyErr_ExceptionMatches(PyExc_TypeError))
return type_error(m);
return NULL;
}
v = PySequence_Tuple(it);
Py_DECREF(it);
return v; return v;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment