diff options
author | Raymond Hettinger <python@rcn.com> | 2004-06-12 05:17:55 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-06-12 05:17:55 (GMT) |
commit | 6c7a00fbaaf6f38009c9640650bf9fcf99233d92 (patch) | |
tree | b9d7de3c9800e1be7c891418596c93a31ab41a3f /Objects/genobject.c | |
parent | 0eb32a65b06613d25aeb18f0104554171bea4840 (diff) | |
download | cpython-6c7a00fbaaf6f38009c9640650bf9fcf99233d92.zip cpython-6c7a00fbaaf6f38009c9640650bf9fcf99233d92.tar.gz cpython-6c7a00fbaaf6f38009c9640650bf9fcf99233d92.tar.bz2 |
* Factor out PyObject_SelfIter().
* Change a XDECREF to DECREF (adding an assertion just to be sure).
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 12 |
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 */ |