bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114)

This commit is contained in:
Mark Shannon 2022-03-31 17:13:25 +01:00 committed by GitHub
parent 44e915028d
commit 74b95d86e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 4 deletions

View file

@ -30,6 +30,17 @@ See also :ref:`Reflection <reflection>`.
.. versionadded:: 3.9
.. c:function:: PyObject* PyFrame_GetBuiltins(PyFrameObject *frame)
Get the *frame*'s ``f_builtins`` attribute.
Return a :term:`strong reference`. The result cannot be ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
Get the *frame* code.
@ -41,6 +52,30 @@ See also :ref:`Reflection <reflection>`.
.. versionadded:: 3.9
.. c:function:: PyObject* PyFrame_GetGenerator(PyFrameObject *frame)
Get the generator, coroutine, or async generator that owns this frame,
or ``NULL`` if this frame is not owned by a generator.
Does not raise an exception, even if the return value is ``NULL``.
Return a :term:`strong reference`, or ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11
.. c:function:: PyObject* PyFrame_GetGlobals(PyFrameObject *frame)
Get the *frame*'s ``f_globals`` attribute.
Return a :term:`strong reference`. The result cannot be ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame)
Get the *frame*'s ``f_locals`` attribute (:class:`dict`).