Skip to content

Commit a4cb319

Browse files
authored
bpo-46355: What's New: Note that PyFrameObject are private (GH-31032)
This adds a slightly more detailed explanation of the change. The most important point is that the changed/removed fields were "subject to change" to begin with.
1 parent 4c0612a commit a4cb319

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

Doc/whatsnew/3.11.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,19 @@ Porting to Python 3.11
759759
which are not available in the limited C API.
760760
(Contributed by Victor Stinner in :issue:`46007`.)
761761

762-
* Changes of the :c:type:`PyFrameObject` structure members:
762+
* Changes of the private :c:type:`PyFrameObject` structure members.
763+
764+
While the documentation notes that the fields of ``PyFrameObject`` are
765+
subject to change at any time, they have been stable for a long time
766+
and were used in several popular extensions.
767+
In Python 3.11, the frame struct was reorganized to allow performance
768+
optimizations. Rather than reading the fields directly, extensions should
769+
use functions:
763770

764771
* ``f_code``: removed, use :c:func:`PyFrame_GetCode` instead.
765772
Warning: the function returns a :term:`strong reference`, need to call
766773
:c:func:`Py_DECREF`.
767-
* ``f_back``: changed, use :c:func:`PyFrame_GetBack`.
774+
* ``f_back``: changed (see below), use :c:func:`PyFrame_GetBack`.
768775
* ``f_builtins``: removed,
769776
use ``PyObject_GetAttrString(frame, "f_builtins")``.
770777
* ``f_globals``: removed,
@@ -773,13 +780,17 @@ Porting to Python 3.11
773780
use ``PyObject_GetAttrString(frame, "f_locals")``.
774781
* ``f_lasti``: removed,
775782
use ``PyObject_GetAttrString(frame, "f_lasti")``.
776-
* ``f_valuesstack``: removed.
777-
* ``f_stackdepth``: removed.
778-
* ``f_gen``: removed.
779-
* ``f_iblock``: removed.
780-
* ``f_state``: removed.
781-
* ``f_blockstack``: removed.
782-
* ``f_localsplus``: removed.
783+
784+
The following fields were removed entirely, as they were details
785+
of the old implementation:
786+
787+
* ``f_valuesstack``
788+
* ``f_stackdepth``
789+
* ``f_gen``
790+
* ``f_iblock``
791+
* ``f_state``
792+
* ``f_blockstack``
793+
* ``f_localsplus``
783794

784795
The Python frame object is now created lazily. A side effect is that the
785796
``f_back`` member must not be accessed directly, since its value is now also

0 commit comments

Comments
 (0)