@@ -837,40 +837,40 @@ Porting to Python 3.11
837
837
which are not available in the limited C API.
838
838
(Contributed by Victor Stinner in :issue: `46007 `.)
839
839
840
- * Changes of the private :c:type: `PyFrameObject ` structure members.
840
+ * The :c:type: `PyFrameObject ` structure member has been moved to the internal C
841
+ API headers.
841
842
842
- While the documentation notes that the fields of ``PyFrameObject `` are
843
- subject to change at any time, they have been stable for a long time
844
- and were used in several popular extensions.
845
- In Python 3.11, the frame struct was reorganized to allow performance
846
- optimizations. Rather than reading the fields directly, extensions should
847
- use functions:
843
+ While the documentation notes that the :c:type: `PyFrameObject ` fields are
844
+ subject to change at any time, they have been stable for a long time and were
845
+ used in several popular extensions.
848
846
849
- * ``f_code ``: removed, use :c:func: `PyFrame_GetCode ` instead.
850
- Warning: the function returns a :term: `strong reference `, need to call
851
- :c:func: `Py_DECREF `.
852
- * ``f_back ``: changed (see below), use :c:func: `PyFrame_GetBack `.
853
- * ``f_builtins ``: removed,
854
- use ``PyObject_GetAttrString((PyObject*)frame, "f_builtins") ``.
855
- * ``f_globals ``: removed,
856
- use ``PyObject_GetAttrString((PyObject*)frame, "f_globals") ``.
857
- * ``f_locals ``: removed,
858
- use ``PyObject_GetAttrString((PyObject*)frame, "f_locals") ``.
859
- * ``f_lasti ``: removed,
860
- use ``PyObject_GetAttrString((PyObject*)frame, "f_lasti") ``.
861
- Code using ``f_lasti `` with ``PyCode_Addr2Line() `` should use
847
+ In Python 3.11, the frame struct was reorganized to allow performance
848
+ optimizations. Some fields were removed entirely, as they were details of the
849
+ old implementation.
850
+
851
+ :c:type: `PyFrameObject ` fields:
852
+
853
+ * ``f_back ``: use :c:func: `PyFrame_GetBack `.
854
+ * ``f_blockstack ``: removed.
855
+ * ``f_builtins ``: use ``PyObject_GetAttrString((PyObject*)frame, "f_builtins") ``.
856
+ * ``f_code ``: use :c:func: `PyFrame_GetCode `.
857
+ * ``f_gen ``: removed.
858
+ * ``f_globals ``: use ``PyObject_GetAttrString((PyObject*)frame, "f_globals") ``.
859
+ * ``f_iblock ``: removed.
860
+ * ``f_lasti ``: use ``PyObject_GetAttrString((PyObject*)frame, "f_lasti") ``.
861
+ Code using ``f_lasti `` with ``PyCode_Addr2Line() `` must use
862
862
:c:func: `PyFrame_GetLineNumber ` instead.
863
-
864
- The following fields were removed entirely, as they were details
865
- of the old implementation:
866
-
867
- * ``f_valuesstack ``
868
- * ``f_stackdepth ``
869
- * `` f_gen ``
870
- * ``f_iblock ``
871
- * `` f_state ``
872
- * ``f_blockstack ``
873
- * ``f_localsplus ``
863
+ * `` f_lineno ``: use :c:func: ` PyFrame_GetLineNumber `
864
+ * `` f_locals ``: use `` PyObject_GetAttrString((PyObject*)frame, "f_locals") ``.
865
+ * `` f_stackdepth ``: removed.
866
+ * `` f_state ``: no public API (renamed to `` f_frame.f_state ``).
867
+ * ``f_trace ``: no public API.
868
+ * ``f_trace_lines ``: use `` PyObject_GetAttrString((PyObject*)frame, "f_trace_lines") ``
869
+ (it also be modified).
870
+ * ``f_trace_opcodes ``: use `` PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes") ``
871
+ (it also be modified).
872
+ * ``f_localsplus ``: no public API (renamed to `` f_frame.localsplus ``).
873
+ * ``f_valuestack ``: removed.
874
874
875
875
The Python frame object is now created lazily. A side effect is that the
876
876
``f_back `` member must not be accessed directly, since its value is now also
@@ -897,9 +897,9 @@ Porting to Python 3.11
897
897
}
898
898
#endif
899
899
900
- Or use ` the pythoncapi_compat project
901
- <https://github.com/pythoncapi/pythoncapi_compat> `__ to get these APIs
902
- on older Python versions.
900
+ Or use the ` pythoncapi_compat project
901
+ <https://github.com/pythoncapi/pythoncapi_compat> `__ to get these two
902
+ functions on older Python versions.
903
903
904
904
* Changes of the :c:type: `PyThreadState ` structure members:
905
905
0 commit comments