mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-42197: Don't create f_locals
dictionary unless we actually need it. (GH-32055)
* `PyFrame_FastToLocalsWithError` and `PyFrame_LocalsToFast` are no longer called during profile and tracing. (Contributed by Fabio Zadrozny) * Make accesses to a frame's `f_locals` safe from C code, not relying on calls to `PyFrame_FastToLocals` or `PyFrame_LocalsToFast`. * Document new `PyFrame_GetLocals` C-API function.
This commit is contained in:
parent
b68431fadb
commit
d7163bb35d
7 changed files with 46 additions and 10 deletions
|
@ -969,7 +969,7 @@ Porting to Python 3.11
|
|||
Code using ``f_lasti`` with ``PyCode_Addr2Line()`` must use
|
||||
:c:func:`PyFrame_GetLineNumber` instead.
|
||||
* ``f_lineno``: use :c:func:`PyFrame_GetLineNumber`
|
||||
* ``f_locals``: use ``PyObject_GetAttrString((PyObject*)frame, "f_locals")``.
|
||||
* ``f_locals``: use :c:func:`PyFrame_GetLocals`.
|
||||
* ``f_stackdepth``: removed.
|
||||
* ``f_state``: no public API (renamed to ``f_frame.f_state``).
|
||||
* ``f_trace``: no public API.
|
||||
|
@ -983,6 +983,12 @@ Porting to Python 3.11
|
|||
computed lazily. The :c:func:`PyFrame_GetBack` function must be called
|
||||
instead.
|
||||
|
||||
Debuggers that accessed the ``f_locals`` directly *must* call
|
||||
`:c:func:`PyFrame_GetLocals` instead. They no longer need to call
|
||||
`:c:func:`PyFrame_FastToLocalsWithError` or :c:func:`PyFrame_LocalsToFast`,
|
||||
in fact they should not call those functions. The necessary updating of the
|
||||
frame is now managed by the virtual machine.
|
||||
|
||||
Code defining ``PyFrame_GetCode()`` on Python 3.8 and older::
|
||||
|
||||
#if PY_VERSION_HEX < 0x030900B1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue