Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 667: PyFrame_GetLocals is no longer new #3793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions peps/pep-0667.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,23 @@ C-API
Extensions to the API
'''''''''''''''''''''

Four new C-API functions will be added::
Three new C-API functions will be added::

PyObject *PyEval_GetFrameLocals(void)
PyObject *PyEval_GetFrameGlobals(void)
PyObject *PyEval_GetFrameBuiltins(void)
PyObject *PyFrame_GetLocals(PyFrameObject *f)

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

``PyFrame_GetLocals(f)`` is equivalent to: ``f.f_locals``.

All these functions will return a new reference.

Changes to existing APIs
''''''''''''''''''''''''

``PyFrame_GetLocals(f)`` is equivalent to ``f.f_locals``, and hence its return value
will change as described above for accessing ``f.f_locals``.

The following C-API functions will be deprecated, as they return borrowed references::

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

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

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

Expand Down Expand Up @@ -209,7 +209,7 @@ PyEval_GetLocals
''''''''''''''''

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

This code::
Expand Down
Loading