Skip to content

Commit d1aae7b

Browse files
authored
PEP 667: PyFrame_GetLocals is no longer new (#3793)
PyFrame_GetLocals was already added back in Python 3.11, so PEP 667 is changing it rather than adding it. (Discrepancy picked up while writing the C API docs update)
1 parent 3b62de3 commit d1aae7b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

peps/pep-0667.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,23 @@ C-API
138138
Extensions to the API
139139
'''''''''''''''''''''
140140

141-
Four new C-API functions will be added::
141+
Three new C-API functions will be added::
142142

143143
PyObject *PyEval_GetFrameLocals(void)
144144
PyObject *PyEval_GetFrameGlobals(void)
145145
PyObject *PyEval_GetFrameBuiltins(void)
146-
PyObject *PyFrame_GetLocals(PyFrameObject *f)
147146

148147
``PyEval_GetFrameLocals()`` is equivalent to: ``locals()``.
149148
``PyEval_GetFrameGlobals()`` is equivalent to: ``globals()``.
150149

151-
``PyFrame_GetLocals(f)`` is equivalent to: ``f.f_locals``.
152-
153150
All these functions will return a new reference.
154151

155152
Changes to existing APIs
156153
''''''''''''''''''''''''
157154

155+
``PyFrame_GetLocals(f)`` is equivalent to ``f.f_locals``, and hence its return value
156+
will change as described above for accessing ``f.f_locals``.
157+
158158
The following C-API functions will be deprecated, as they return borrowed references::
159159

160160
PyEval_GetLocals()
@@ -170,7 +170,7 @@ The following functions should be used instead::
170170
which return new references.
171171

172172
The semantics of ``PyEval_GetLocals()`` is changed as it now returns a
173-
view of the frame locals, not a dictionary.
173+
proxy for the frame locals in optimized frames, not a dictionary.
174174

175175
The following three functions will become no-ops, and will be deprecated::
176176

@@ -208,7 +208,7 @@ PyEval_GetLocals
208208
''''''''''''''''
209209

210210
Because ``PyEval_GetLocals()`` returns a borrowed reference, it requires
211-
the dictionary to be cached on the frame, extending its lifetime and
211+
the proxy mapping to be cached on the frame, extending its lifetime and
212212
creating a cycle. ``PyEval_GetFrameLocals()`` should be used instead.
213213

214214
This code::

0 commit comments

Comments
 (0)