@@ -27,126 +27,186 @@ Latest version of the header file:
2727Python 3.11
2828-----------
2929
30- ::
30+ .. c : function :: void PyThreadState_EnterTracing (PyThreadState * tstate)
3131
32- // Not available on PyPy
33- void PyThreadState_EnterTracing(PyThreadState *tstate);
34- // Not available on PyPy
35- void PyThreadState_LeaveTracing(PyThreadState *tstate);
32+ See `PyThreadState_EnterTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_EnterTracing >`__.
33+
34+ Not available on PyPy.
35+
36+ .. c :function :: void PyThreadState_LeaveTracing (PyThreadState *tstate)
37+
38+ See `PyThreadState_LeaveTracing() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_LeaveTracing >`__.
39+
40+ Not available on PyPy
3641
3742Python 3.10
3843-----------
3944
40- ::
45+ .. c :function :: PyObject* Py_NewRef (PyObject *obj)
46+
47+ See `Py_NewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_NewRef >`__.
48+
49+ .. c :function :: PyObject* Py_XNewRef (PyObject *obj)
50+
51+ See `Py_XNewRef() documentation <https://docs.python.org/dev/c-api/refcounting.html#c.Py_XNewRef >`__.
52+
53+ .. c :function :: int Py_Is (PyObject *x, PyObject *y)
54+
55+ See `Py_Is() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_Is >`__.
56+
57+ .. c :function :: int Py_IsNone (PyObject *x)
58+
59+ See `Py_IsNone() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsNone >`__.
60+
61+ .. c :function :: int Py_IsTrue (PyObject *x)
62+
63+ See `Py_IsTrue() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsTrue >`__.
4164
42- PyObject* Py_NewRef(PyObject *obj);
43- PyObject* Py_XNewRef(PyObject *obj);
44- int Py_Is(PyObject *x, PyObject *y);
45- int Py_IsNone(PyObject *x);
46- int Py_IsTrue(PyObject *x);
47- int Py_IsFalse(PyObject *x);
65+ .. c :function :: int Py_IsFalse (PyObject *x)
4866
49- int PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value);
67+ See `Py_IsFalse() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IsFalse >`__.
68+
69+ .. c :function :: int PyModule_AddObjectRef (PyObject *module, const char *name, PyObject *value)
70+
71+ See `PyModule_AddObjectRef() documentation <https://docs.python.org/dev/c-api/module.html#c.PyModule_AddObjectRef >`__.
5072
5173Python 3.9
5274----------
5375
5476PyObject
5577^^^^^^^^
5678
57- ::
79+ .. c :function :: void Py_SET_REFCNT (PyObject *ob, Py_ssize_t refcnt)
80+
81+ See `Py_SET_REFCNT() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_REFCNT >`__.
82+
83+ .. c :function :: void Py_SET_TYPE (PyObject *ob, PyTypeObject *type)
84+
85+ See `Py_SET_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_TYPE >`__.
86+
87+ .. c :function :: void Py_SET_SIZE (PyVarObject *ob, Py_ssize_t size)
88+
89+ See `Py_SET_SIZE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_SIZE >`__.
5890
59- void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt);
60- void Py_SET_TYPE(PyObject *ob, PyTypeObject *type);
61- void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size);
62- int Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type);
91+ .. c :function :: int Py_IS_TYPE (const PyObject *ob, const PyTypeObject *type)
92+
93+ See `Py_IS_TYPE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_IS_TYPE >`__.
94+
95+ .. c :function :: PyObject* PyObject_CallNoArgs (PyObject *func)
96+
97+ See `PyObject_CallNoArgs() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallNoArgs >`__.
98+
99+ .. c :function :: PyObject* PyObject_CallOneArg (PyObject *func, PyObject *arg)
100+
101+ See `PyObject_CallOneArg() documentation <https://docs.python.org/dev/c-api/call.html#c.PyObject_CallOneArg >`__.
63102
64- PyObject* PyObject_CallNoArgs(PyObject *func);
65- PyObject* PyObject_CallOneArg(PyObject *func, PyObject *arg);
66103
67104PyFrameObject
68105^^^^^^^^^^^^^
69106
70- ::
107+ .. c :function :: PyCodeObject* PyFrame_GetCode (PyFrameObject *frame)
108+
109+ See `PyFrame_GetCode() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetCode >`__.
110+
111+ .. c :function :: PyFrameObject* PyFrame_GetBack (PyFrameObject *frame)
112+
113+ See `PyFrame_GetBack() documentation <https://docs.python.org/dev/c-api/reflection.html#c.PyFrame_GetBack >`__.
114+
115+ Not available on PyPy
71116
72- PyCodeObject* PyFrame_GetCode(PyFrameObject *frame);
73- // Not available on PyPy
74- PyFrameObject* PyFrame_GetBack(PyFrameObject *frame);
75117
76118PyThreadState
77119^^^^^^^^^^^^^
78120
79- ::
121+ .. c :function :: PyFrameObject* PyThreadState_GetFrame (PyThreadState *tstate)
122+
123+ See `PyThreadState_GetFrame() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetFrame >`__.
124+
125+ Not available on PyPy
126+
127+ .. c :function :: PyInterpreterState* PyThreadState_GetInterpreter (PyThreadState *tstate)
128+
129+ See `PyThreadState_GetInterpreter() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetInterpreter >`__.
80130
81- // Not available on PyPy
82- PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate);
83- PyInterpreterState* PyThreadState_GetInterpreter(PyThreadState *tstate);
84- // Availability: Python 3.7. Not available on PyPy.
85- uint64_t PyThreadState_GetID(PyThreadState *tstate);
131+ .. c : function :: uint64_t PyThreadState_GetID (PyThreadState * tstate)
132+
133+ See ` PyThreadState_GetID() documentation < https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetID >`__.
134+
135+ Availability: Python 3.7. Not available on PyPy.
86136
87137PyInterpreterState
88138^^^^^^^^^^^^^^^^^^
89139
90- ::
140+ .. c :function :: PyInterpreterState* PyInterpreterState_Get (void)
141+
142+ See `PyInterpreterState_Get() documentation <https:// docs.python.org/dev/c-api/init.html#c.PyInterpreterState_Get>`__.
91143
92- PyInterpreterState* PyInterpreterState_Get(void);
93144
94145GC protocol
95146^^^^^^^^^^^
96147
97- ::
148+ .. c:function:: int PyObject_GC_IsTracked(PyObject* obj)
149+
150+ See `PyObject_GC_IsTracked() documentation <https:// docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsTracked>`__.
151+
152+ Not available on PyPy.
153+
154+ .. c:function:: int PyObject_GC_IsFinalized(PyObject *obj)
98155
99- // Not available on PyPy.
100- int PyObject_GC_IsTracked(PyObject* obj);
101- // Availability: Python 3.4. Not available on PyPy.
102- int PyObject_GC_IsFinalized(PyObject *obj);
156+ See `PyObject_GC_IsFinalized() documentation <https://docs.python.org/dev/c-api/gcsupport.html#c.PyObject_GC_IsFinalized >`__.
157+
158+ Availability: Python 3.4. Not available on PyPy.
103159
104160Module helper
105161^^^^^^^^^^^^^
106162
107- ::
163+ .. c : function :: int PyModule_AddType (PyObject * module, PyTypeObject *type)
108164
109- int PyModule_AddType(PyObject *module, PyTypeObject *type);
165+ See ` PyModule_AddType() documentation < https://docs.python.org/dev/c-api/module.html#c.PyModule_AddType >`__.
110166
111167Python 3.5.2
112168------------
113169
114- ::
170+ .. c : macro :: Py_SETREF(op, op2)
115171
116- Py_SETREF(op, op2)
117- Py_XSETREF(op, op2)
172+ .. c :macro :: Py_XSETREF(op, op2)
118173
119174 Python 3.4
120175----------
121176
122- ::
177+ .. c : macro :: Py_UNUSED(name)
123178
124- Py_UNUSED(name)
179+ See ` Py_UNUSED() documentation < https://docs.python.org/dev/c-api/intro.html#c.Py_UNUSED >`__.
125180
126181Borrow variant
127182--------------
128183
129184To ease migration of C extensions to the new C API, a variant is provided
130- to return borrowed references rather than strong references::
185+ to return borrowed references rather than strong references.
186+
187+ These functions are only available in ``pythoncapi_compat.h `` and are not
188+ part of the Python C API.
189+
190+ .. c :function :: PyObject* _Py_StealRef (PyObject *ob)
191+
192+ Similar to ``Py_DECREF(ob); return ob; ``.
131193
132- // Similar to "Py_DECREF(ob); return ob;"
133- PyObject* _Py_StealRef(PyObject *ob);
194+ .. c :function :: PyObject* _Py_XStealRef (PyObject *ob)
134195
135- // Similar to "Py_XDECREF(ob); return ob;"
136- PyObject* _Py_XStealRef(PyObject *ob);
196+ Similar to ``Py_XDECREF(ob); return ob; ``.
137197
138- // PyThreadState_GetFrame(). Not available on PyPy.
139- PyFrameObject* _PyThreadState_GetFrameBorrow(PyThreadState *tstate)
198+ .. c :function :: PyFrameObject* _PyThreadState_GetFrameBorrow (PyThreadState *tstate)
140199
141- // PyFrame_GetCode()
142- PyCodeObject* _PyFrame_GetCodeBorrow(PyFrameObject *frame)
200+ :c:func: `PyThreadState_GetFrame ` variant. Not available on PyPy.
143201
144- // PyFrame_GetBack(). Not available on PyPy.
145- PyFrameObject* _PyFrame_GetBackBorrow(PyFrameObject *frame)
202+ .. c :function :: PyCodeObject* _PyFrame_GetCodeBorrow (PyFrameObject *frame)
203+
204+ :c:func: `PyFrame_GetCode ` variant.
205+
206+ .. c :function :: PyFrameObject* _PyFrame_GetBackBorrow (PyFrameObject *frame)
207+
208+ :c:func: `PyFrame_GetBack ` variant Not available on PyPy.
146209
147210For example, ``tstate->frame `` can be replaced with
148211``_PyThreadState_GetFrameBorrow(tstate) `` to avoid accessing directly
149212``PyThreadState.frame `` member.
150-
151- These functions are only available in ``pythoncapi_compat.h `` and are not
152- part of the Python C API.
0 commit comments