[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.16.8.37,2.16.8.38
Guido van Rossum
gvanrossum@users.sourceforge.net
Mon, 11 Jun 2001 11:45:12 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv16077
Modified Files:
Tag: descr-branch
typeobject.c
Log Message:
The wrapper function for tp_iternext can't be wrap_unaryfunc, because
the tp_iternext slot doesn't always set the exception. Fix this by
adding a custom wrapper, wrap_next().
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.37
retrieving revision 2.16.8.38
diff -C2 -r2.16.8.37 -r2.16.8.38
*** typeobject.c 2001/06/11 15:29:53 2.16.8.37
--- typeobject.c 2001/06/11 18:45:10 2.16.8.38
***************
*** 1540,1545 ****
};
static struct wrapperbase tab_next[] = {
! {"next", (wrapperfunc)wrap_unaryfunc, "x.next() -> next value"},
{0}
};
--- 1540,1559 ----
};
+ static PyObject *
+ wrap_next(PyObject *self, PyObject *args, void *wrapped)
+ {
+ unaryfunc func = (unaryfunc)wrapped;
+ PyObject *res;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ res = (*func)(self);
+ if (res == NULL && !PyErr_Occurred())
+ PyErr_SetNone(PyExc_StopIteration);
+ return res;
+ }
+
static struct wrapperbase tab_next[] = {
! {"next", (wrapperfunc)wrap_next, "x.next() -> next value"},
{0}
};