Skip to content

Commit b0f886d

Browse files
authored
bpo-46836: Add Doc/c-api/frame.rst (GH-32051)
Reorganize the documentation of the PyFrameObject C API.
1 parent 3ac4e78 commit b0f886d

File tree

5 files changed

+51
-47
lines changed

5 files changed

+51
-47
lines changed

Doc/c-api/concrete.rst

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Other Objects
111111
memoryview.rst
112112
weakref.rst
113113
capsule.rst
114+
frame.rst
114115
gen.rst
115116
coro.rst
116117
contextvars.rst

Doc/c-api/frame.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. highlight:: c
2+
3+
Frame Objects
4+
-------------
5+
6+
.. c:type:: PyFrameObject
7+
8+
The C structure of the objects used to describe frame objects.
9+
10+
The structure is not part of the C API.
11+
12+
.. versionchanged:: 3.11
13+
The structure moved to the internal C API headers.
14+
15+
The :c:func:`PyEval_GetFrame` and :c:func:`PyThreadState_GetFrame` functions
16+
can be used to get a frame object.
17+
18+
See also :ref:`Reflection <reflection>`.
19+
20+
21+
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
22+
23+
Get the *frame* next outer frame.
24+
25+
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer
26+
frame.
27+
28+
*frame* must not be ``NULL``.
29+
30+
.. versionadded:: 3.9
31+
32+
33+
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
34+
35+
Get the *frame* code.
36+
37+
Return a :term:`strong reference`.
38+
39+
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
40+
41+
.. versionadded:: 3.9
42+
43+
44+
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
45+
46+
Return the line number that *frame* is currently executing.
47+
48+
*frame* must not be ``NULL``.

Doc/c-api/reflection.rst

-29
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,6 @@ Reflection
3131
See also :c:func:`PyThreadState_GetFrame`.
3232
3333
34-
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
35-
36-
Get the *frame* next outer frame.
37-
38-
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer frame.
39-
40-
*frame* must not be ``NULL``.
41-
42-
.. versionadded:: 3.9
43-
44-
45-
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
46-
47-
Get the *frame* code.
48-
49-
Return a :term:`strong reference`.
50-
51-
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
52-
53-
.. versionadded:: 3.9
54-
55-
56-
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
57-
58-
Return the line number that *frame* is currently executing.
59-
60-
*frame* must not be ``NULL``.
61-
62-
6334
.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
6435
6536
Return the name of *func* if it is a function, class or instance object, else the

Doc/c-api/veryhigh.rst

-14
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,6 @@ the same library that the Python runtime is using.
286286
<keyword-only_parameter>` arguments and a closure tuple of cells.
287287
288288
289-
.. c:type:: PyFrameObject
290-
291-
The C structure of the objects used to describe frame objects.
292-
293-
The structure is only part of the internal C API: fields should not be
294-
access directly. Use getter functions like :c:func:`PyFrame_GetCode` and
295-
:c:func:`PyFrame_GetBack`.
296-
297-
Debuggers and profilers can use the limited C API to access this structure.
298-
299-
.. versionchanged:: 3.11
300-
The structure moved to the internal C API headers.
301-
302-
303289
.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
304290
305291
Evaluate an execution frame. This is a simplified interface to

Doc/whatsnew/3.11.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,8 @@ Porting to Python 3.11
968968
* ``f_stackdepth``: removed.
969969
* ``f_state``: no public API (renamed to ``f_frame.f_state``).
970970
* ``f_trace``: no public API.
971-
* ``f_trace_lines``: use ``PyObject_GetAttrString((PyObject*)frame, "f_trace_lines")``
972-
(it also be modified).
973-
* ``f_trace_opcodes``: use ``PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes")``
974-
(it also be modified).
971+
* ``f_trace_lines``: use ``PyObject_GetAttrString((PyObject*)frame, "f_trace_lines")``.
972+
* ``f_trace_opcodes``: use ``PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes")``.
975973
* ``f_localsplus``: no public API (renamed to ``f_frame.localsplus``).
976974
* ``f_valuestack``: removed.
977975

0 commit comments

Comments
 (0)