mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
There's no need for generators to define an explicit next() method.
This commit is contained in:
parent
674eae65ea
commit
a64295b43a
1 changed files with 1 additions and 22 deletions
|
@ -165,21 +165,6 @@ gen_iternext(genobject *gen)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
gen_next(genobject *gen)
|
|
||||||
{
|
|
||||||
PyObject *result;
|
|
||||||
|
|
||||||
result = gen_iternext(gen);
|
|
||||||
|
|
||||||
if (result == NULL && !PyErr_Occurred()) {
|
|
||||||
PyErr_SetObject(PyExc_StopIteration, Py_None);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
gen_getiter(PyObject *gen)
|
gen_getiter(PyObject *gen)
|
||||||
{
|
{
|
||||||
|
@ -187,12 +172,6 @@ gen_getiter(PyObject *gen)
|
||||||
return gen;
|
return gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct PyMethodDef gen_methods[] = {
|
|
||||||
{"next", (PyCFunction)gen_next, METH_NOARGS,
|
|
||||||
"next() -- get the next value, or raise StopIteration"},
|
|
||||||
{NULL, NULL} /* Sentinel */
|
|
||||||
};
|
|
||||||
|
|
||||||
static PyMemberDef gen_memberlist[] = {
|
static PyMemberDef gen_memberlist[] = {
|
||||||
{"gi_frame", T_OBJECT, offsetof(genobject, gi_frame), RO},
|
{"gi_frame", T_OBJECT, offsetof(genobject, gi_frame), RO},
|
||||||
{"gi_running", T_INT, offsetof(genobject, gi_running), RO},
|
{"gi_running", T_INT, offsetof(genobject, gi_running), RO},
|
||||||
|
@ -229,7 +208,7 @@ statichere PyTypeObject gentype = {
|
||||||
0, /* tp_weaklistoffset */
|
0, /* tp_weaklistoffset */
|
||||||
(getiterfunc)gen_getiter, /* tp_iter */
|
(getiterfunc)gen_getiter, /* tp_iter */
|
||||||
(iternextfunc)gen_iternext, /* tp_iternext */
|
(iternextfunc)gen_iternext, /* tp_iternext */
|
||||||
gen_methods, /* tp_methods */
|
0, /* tp_methods */
|
||||||
gen_memberlist, /* tp_members */
|
gen_memberlist, /* tp_members */
|
||||||
0, /* tp_getset */
|
0, /* tp_getset */
|
||||||
0, /* tp_base */
|
0, /* tp_base */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue