mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
gh-79940: add introspection API for asynchronous generators to inspect
module (#11590)
This commit is contained in:
parent
aa0a73d1bc
commit
ced13c96a4
6 changed files with 199 additions and 2 deletions
|
@ -1520,6 +1520,15 @@ ag_getcode(PyGenObject *gen, void *Py_UNUSED(ignored))
|
|||
return _gen_getcode(gen, "ag_code");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
ag_getsuspended(PyAsyncGenObject *ag, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (ag->ag_frame_state == FRAME_SUSPENDED) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyGetSetDef async_gen_getsetlist[] = {
|
||||
{"__name__", (getter)gen_get_name, (setter)gen_set_name,
|
||||
PyDoc_STR("name of the async generator")},
|
||||
|
@ -1529,6 +1538,7 @@ static PyGetSetDef async_gen_getsetlist[] = {
|
|||
PyDoc_STR("object being awaited on, or None")},
|
||||
{"ag_frame", (getter)ag_getframe, NULL, NULL},
|
||||
{"ag_code", (getter)ag_getcode, NULL, NULL},
|
||||
{"ag_suspended", (getter)ag_getsuspended, NULL, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue