1919
2020/*[clinic input]
2121class generator "PyGenObject *" "&PyGen_Type"
22+ class async_generator "PyAsyncGenObject *" "&PyAsyncGen_Type"
2223[clinic start generated code]*/
23- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=a6c98fdc710c6976 ]*/
24+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=403b2ee985491847 ]*/
2425
2526#include "clinic/genobject.c.h"
2627
@@ -810,6 +811,12 @@ gen_getrunning_get_impl(PyGenObject *self)
810811 Py_RETURN_FALSE ;
811812}
812813
814+ static PyObject *
815+ gen_getsuspended_lock_held (PyGenObject * self )
816+ {
817+ return PyBool_FromLong (FRAME_STATE_SUSPENDED (self -> gi_frame_state ));
818+ }
819+
813820/*[clinic input]
814821@getter
815822@critical_section
@@ -820,8 +827,7 @@ static PyObject *
820827gen_getsuspended_get_impl (PyGenObject * self )
821828/*[clinic end generated code: output=a0345f9be186eda3 input=880e9fb8436726cb]*/
822829{
823- PyGenObject * gen = _PyGen_CAST (self );
824- return PyBool_FromLong (FRAME_STATE_SUSPENDED (gen -> gi_frame_state ));
830+ return PyBool_FromLong (FRAME_STATE_SUSPENDED (self -> gi_frame_state ));
825831}
826832
827833static PyObject *
@@ -837,15 +843,17 @@ gen_getframe_lock_held(PyGenObject *self, const char *name)
837843 return _Py_XNewRef ((PyObject * )_PyFrame_GetFrameObject (& gen -> gi_iframe ));
838844}
839845
846+ /*[clinic input]
847+ @critical_section
848+ @getter
849+ generator.gi_frame
850+ [clinic start generated code]*/
851+
840852static PyObject *
841- gen_getframe (PyObject * self , void * Py_UNUSED (ignored ))
853+ generator_gi_frame_get_impl (PyGenObject * self )
854+ /*[clinic end generated code: output=8e17169979687334 input=70e20e834b852c3a]*/
842855{
843- PyGenObject * gen = _PyGen_CAST (self );
844- PyObject * res ;
845- Py_BEGIN_CRITICAL_SECTION (gen );
846- res = gen_getframe_lock_held (gen , "gi_frame" );
847- Py_END_CRITICAL_SECTION ();
848- return res ;
856+ return gen_getframe_lock_held (self , "gi_frame" );
849857}
850858
851859static PyObject *
@@ -873,7 +881,7 @@ static PyGetSetDef gen_getsetlist[] = {
873881 PyDoc_STR ("object being iterated by yield from, or None" )},
874882 GEN_GETRUNNING_GETSETDEF
875883 GEN_GETSUSPENDED_GETSETDEF
876- { "gi_frame" , gen_getframe , NULL , NULL },
884+ GENERATOR_GI_FRAME_GETSETDEF
877885 {"gi_code" , gen_getcode , NULL , NULL },
878886 {NULL } /* Sentinel */
879887};
@@ -1649,14 +1657,17 @@ ag_getcode(PyObject *gen, void *Py_UNUSED(ignored))
16491657 return _gen_getcode ((PyGenObject * )gen , "ag_code" );
16501658}
16511659
1660+ /*[clinic input]
1661+ @critical_section
1662+ @getter
1663+ async_generator.ag_suspended as ag_getsuspended
1664+ [clinic start generated code]*/
1665+
16521666static PyObject *
1653- ag_getsuspended (PyObject * self , void * Py_UNUSED (ignored ))
1667+ ag_getsuspended_get_impl (PyAsyncGenObject * self )
1668+ /*[clinic end generated code: output=f9c6d455edce4c50 input=e463d3db950251a3]*/
16541669{
1655- PyAsyncGenObject * ag = _PyAsyncGenObject_CAST (self );
1656- if (FRAME_STATE_SUSPENDED (ag -> ag_frame_state )) {
1657- Py_RETURN_TRUE ;
1658- }
1659- Py_RETURN_FALSE ;
1670+ return gen_getsuspended_lock_held (_PyGen_CAST (self ));
16601671}
16611672
16621673static PyGetSetDef async_gen_getsetlist [] = {
@@ -1668,7 +1679,7 @@ static PyGetSetDef async_gen_getsetlist[] = {
16681679 PyDoc_STR ("object being awaited on, or None" )},
16691680 {"ag_frame" , ag_getframe , NULL , NULL },
16701681 {"ag_code" , ag_getcode , NULL , NULL },
1671- { "ag_suspended" , ag_getsuspended , NULL , NULL },
1682+ AG_GETSUSPENDED_GETSETDEF
16721683 {NULL } /* Sentinel */
16731684};
16741685
0 commit comments