Use proper API for iter.__next__().

This commit is contained in:
Georg Brandl 2007-11-24 20:42:02 +00:00
parent b078925154
commit 5fb8eb9e41
1 changed files with 3 additions and 8 deletions

View File

@ -2945,8 +2945,6 @@ string_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
it = PyObject_GetIter(x); it = PyObject_GetIter(x);
if (it == NULL) if (it == NULL)
goto error; goto error;
// XXX(brett.cannon): No API for this?
iternext = *Py_Type(it)->tp_iternext;
/* Run the iterator to exhaustion */ /* Run the iterator to exhaustion */
for (i = 0; ; i++) { for (i = 0; ; i++) {
@ -2954,13 +2952,10 @@ string_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_ssize_t value; Py_ssize_t value;
/* Get the next item */ /* Get the next item */
item = iternext(it); item = PyIter_Next(it);
if (item == NULL) { if (item == NULL) {
if (PyErr_Occurred()) { if (PyErr_Occurred())
if (!PyErr_ExceptionMatches(PyExc_StopIteration)) goto error;
goto error;
PyErr_Clear();
}
break; break;
} }