@@ -115,8 +115,8 @@ typedef struct {
115115
116116 PyFrameObject * gi_frame ;
117117
118- /* True if generator is being executed. */
119- int gi_running ;
118+ /* True if generator is being executed. */
119+ int gi_running ;
120120} genobject ;
121121
122122static PyObject *
@@ -207,14 +207,27 @@ gen_getiter(PyObject *gen)
207207
208208static struct PyMethodDef gen_methods [] = {
209209 {"next" , (PyCFunction )gen_next , METH_VARARGS ,
210- "next() -- get the next value, or raise StopIteration" },
210+ "next() -- get the next value, or raise StopIteration" },
211211 {NULL , NULL } /* Sentinel */
212212};
213213
214214static PyObject *
215215gen_getattr (genobject * gen , char * name )
216216{
217- return Py_FindMethod (gen_methods , (PyObject * )gen , name );
217+ PyObject * result ;
218+
219+ if (strcmp (name , "gi_frame" ) == 0 ) {
220+ result = (PyObject * )gen -> gi_frame ;
221+ assert (result != NULL );
222+ Py_INCREF (result );
223+ }
224+ else if (strcmp (name , "gi_running" ) == 0 )
225+ result = (PyObject * )PyInt_FromLong ((long )gen -> gi_running );
226+ else if (strcmp (name , "__members__" ) == 0 )
227+ result = Py_BuildValue ("[ss]" , "gi_frame" , "gi_running" );
228+ else
229+ result = Py_FindMethod (gen_methods , (PyObject * )gen , name );
230+ return result ;
218231}
219232
220233statichere PyTypeObject gentype = {
0 commit comments