@@ -7,18 +7,48 @@ Reflection
77
88.. c :function :: PyObject* PyEval_GetBuiltins (void)
99
10+ .. deprecated:: 3.13
11+
12+ Use :c:func:`PyEval_GetFrameBuiltins` instead.
13+
1014 Return a dictionary of the builtins in the current execution frame,
1115 or the interpreter of the thread state if no frame is currently executing.
1216
1317
1418.. c:function:: PyObject* PyEval_GetLocals(void)
1519
16- Return a dictionary of the local variables in the current execution frame,
20+ .. deprecated:: 3.13
21+
22+ Use either :c:func:`PyEval_GetFrameLocals` to obtain the same behaviour as calling
23+ :func:`locals` in Python code, or else call :c:func:`PyFrame_GetLocals` on the result
24+ of :c:func:`PyEval_GetFrame` to access the :attr:`~frame.f_locals` attribute of the
25+ currently executing frame.
26+
27+ Return a mapping providing access to the local variables in the current execution frame,
1728 or ``NULL`` if no frame is currently executing.
1829
30+ Refer to :func:`locals` for details of the mapping returned at different scopes.
31+
32+ As this function returns a :term:`borrowed reference`, the dictionary returned for
33+ :term:`optimized scopes <optimized scope>` is cached on the frame object and will remain
34+ alive as long as the frame object does. Unlike :c:func:`PyEval_GetFrameLocals` and
35+ :func:`locals`, subsequent calls to this function in the same frame will update the
36+ contents of the cached dictionary to reflect changes in the state of the local variables
37+ rather than returning a new snapshot.
38+
39+ .. versionchanged:: 3.13
40+ As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, and
41+ :attr:`FrameType.f_locals <frame.f_locals>` no longer make use of the shared cache
42+ dictionary. Refer to the :ref:`What's New entry <whatsnew313-locals-semantics>` for
43+ additional details.
44+
1945
2046.. c:function:: PyObject* PyEval_GetGlobals(void)
2147
48+ .. deprecated:: 3.13
49+
50+ Use :c:func:`PyEval_GetFrameGlobals` instead.
51+
2252 Return a dictionary of the global variables in the current execution frame,
2353 or ``NULL`` if no frame is currently executing.
2454
@@ -31,6 +61,36 @@ Reflection
3161 See also :c:func:`PyThreadState_GetFrame`.
3262
3363
64+ .. c:function:: PyObject* PyEval_GetFrameBuiltins(void)
65+
66+ Return a dictionary of the builtins in the current execution frame,
67+ or the interpreter of the thread state if no frame is currently executing.
68+
69+ .. versionadded:: 3.13
70+
71+
72+ .. c:function:: PyObject* PyEval_GetFrameLocals(void)
73+
74+ Return a dictionary of the local variables in the current execution frame,
75+ or ``NULL`` if no frame is currently executing. Equivalent to calling
76+ :func:`locals` in Python code.
77+
78+ To access :attr:`~frame.f_locals` on the current frame without making an independent
79+ snapshot in :term:`optimized scopes <optimized scope>`, call :c:func:`PyFrame_GetLocals`
80+ on the result of :c:func:`PyEval_GetFrame`.
81+
82+ .. versionadded:: 3.13
83+
84+
85+ .. c:function:: PyObject* PyEval_GetFrameGlobals(void)
86+
87+ Return a dictionary of the global variables in the current execution frame,
88+ or ``NULL`` if no frame is currently executing. Equivalent to calling
89+ :func:`globals` in Python code.
90+
91+ .. versionadded:: 3.13
92+
93+
3494.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
3595
3696 Return the name of *func * if it is a function, class or instance object, else the
0 commit comments