summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/genobject.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 0f7373a..a604bcb 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -50,7 +50,8 @@ gen_iternext(PyGenObject *gen)
/* Don't keep the reference to f_back any longer than necessary. It
* may keep a chain of frames alive or it could create a reference
* cycle. */
- Py_XDECREF(f->f_back);
+ assert(f->f_back != NULL);
+ Py_DECREF(f->f_back);
f->f_back = NULL;
/* If the generator just returned (as opposed to yielding), signal
@@ -63,13 +64,6 @@ gen_iternext(PyGenObject *gen)
return result;
}
-static PyObject *
-gen_getiter(PyObject *gen)
-{
- Py_INCREF(gen);
- return gen;
-}
-
static PyMemberDef gen_memberlist[] = {
{"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), RO},
{"gi_running", T_INT, offsetof(PyGenObject, gi_running), RO},
@@ -104,7 +98,7 @@ PyTypeObject PyGen_Type = {
0, /* tp_clear */
0, /* tp_richcompare */
offsetof(PyGenObject, gi_weakreflist), /* tp_weaklistoffset */
- (getiterfunc)gen_getiter, /* tp_iter */
+ PyObject_SelfIter, /* tp_iter */
(iternextfunc)gen_iternext, /* tp_iternext */
0, /* tp_methods */
gen_memberlist, /* tp_members */