summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-08 16:40:27 (GMT)
committerGitHub <noreply@github.com>2022-11-08 16:40:27 (GMT)
commit4d5fcca273b24a5566f1507758e5aae60cdf8a98 (patch)
treeac00d021776bd95cddd48ca272e07d8711d73922 /Doc/c-api
parentacf4d5d5bdecbc8756276731e09bae245d88518d (diff)
downloadcpython-4d5fcca273b24a5566f1507758e5aae60cdf8a98.zip
cpython-4d5fcca273b24a5566f1507758e5aae60cdf8a98.tar.gz
cpython-4d5fcca273b24a5566f1507758e5aae60cdf8a98.tar.bz2
gh-91248: Add PyFrame_GetVar() function (#95712)
Add PyFrame_GetVar() and PyFrame_GetVarString() functions to get a frame variable by its name. Move PyFrameObject C API tests from test_capi to test_frame.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/frame.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/c-api/frame.rst b/Doc/c-api/frame.rst
index 46ce700..4a062dd 100644
--- a/Doc/c-api/frame.rst
+++ b/Doc/c-api/frame.rst
@@ -79,6 +79,25 @@ See also :ref:`Reflection <reflection>`.
.. versionadded:: 3.11
+.. c:function:: PyObject* PyFrame_GetVar(PyFrameObject *frame, PyObject *name)
+
+ Get the variable *name* of *frame*.
+
+ * Return a :term:`strong reference` to the variable value on success.
+ * Raise :exc:`NameError` and return ``NULL`` if the variable does not exist.
+ * Raise an exception and return ``NULL`` on error.
+
+ .. versionadded:: 3.12
+
+
+.. c:function:: PyObject* PyFrame_GetVarString(PyFrameObject *frame, const char *name)
+
+ Similar to :c:func:`PyFrame_GetVar`, but the variable name is a C string
+ encoded in UTF-8.
+
+ .. versionadded:: 3.12
+
+
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame)
Get the *frame*'s ``f_locals`` attribute (:class:`dict`).