Skip to content

Commit 6553dc2

Browse files
Merge branch 'main' into err-programtext
2 parents db0b5c8 + 4420cf4 commit 6553dc2

File tree

91 files changed

+1657
-758
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1657
-758
lines changed

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ htmlview: html
152152
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
153153

154154
.PHONY: htmllive
155-
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
155+
htmllive: SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-autobuild
156156
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
157157
htmllive: _ensure-sphinx-autobuild html
158158

Doc/c-api/code.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ bound into a function.
9696
Return the line number of the instruction that occurs on or before ``byte_offset`` and ends after it.
9797
If you just need the line number of a frame, use :c:func:`PyFrame_GetLineNumber` instead.
9898
99-
For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626
100-
<https://peps.python.org/pep-0626/#out-of-process-debuggers-and-profilers>`_.
99+
For efficiently iterating over the line numbers in a code object, use :pep:`the API described in PEP 626
100+
<0626#out-of-process-debuggers-and-profilers>`.
101101
102102
.. c:function:: int PyCode_Addr2Location(PyObject *co, int byte_offset, int *start_line, int *start_column, int *end_line, int *end_column)
103103

Doc/c-api/complex.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pointers. This is consistent throughout the API.
7979
If *num* is null and *exp* is not a positive real number,
8080
this method returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`.
8181
82+
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
83+
8284
8385
Complex Numbers as Python Objects
8486
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Doc/c-api/exceptions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ the variables:
10041004
single: PyExc_OverflowError (C var)
10051005
single: PyExc_PermissionError (C var)
10061006
single: PyExc_ProcessLookupError (C var)
1007+
single: PyExc_PythonFinalizationError (C var)
10071008
single: PyExc_RecursionError (C var)
10081009
single: PyExc_ReferenceError (C var)
10091010
single: PyExc_RuntimeError (C var)
@@ -1096,6 +1097,8 @@ the variables:
10961097
+-----------------------------------------+---------------------------------+----------+
10971098
| :c:data:`PyExc_ProcessLookupError` | :exc:`ProcessLookupError` | |
10981099
+-----------------------------------------+---------------------------------+----------+
1100+
| :c:data:`PyExc_PythonFinalizationError` | :exc:`PythonFinalizationError` | |
1101+
+-----------------------------------------+---------------------------------+----------+
10991102
| :c:data:`PyExc_RecursionError` | :exc:`RecursionError` | |
11001103
+-----------------------------------------+---------------------------------+----------+
11011104
| :c:data:`PyExc_ReferenceError` | :exc:`ReferenceError` | |

Doc/c-api/long.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
509509
Currently, ``-1`` corresponds to
510510
``Py_ASNATIVEBYTES_NATIVE_ENDIAN | Py_ASNATIVEBYTES_UNSIGNED_BUFFER``.
511511
512+
.. c:namespace:: NULL
513+
512514
============================================= ======
513515
Flag Value
514516
============================================= ======

Doc/c-api/module.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ The available slot types are:
421421
422422
Specifies one of the following values:
423423
424+
.. c:namespace:: NULL
425+
424426
.. c:macro:: Py_MOD_GIL_USED
425427
426428
The module depends on the presence of the global interpreter lock (GIL),

Doc/c-api/monitoring.rst

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Managing the Monitoring State
133133
Monitoring states can be managed with the help of monitoring scopes. A scope
134134
would typically correspond to a python function.
135135
136-
.. :c:function:: int PyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, const uint8_t *event_types, Py_ssize_t length)
136+
.. c:function:: int PyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, const uint8_t *event_types, Py_ssize_t length)
137137
138138
Enter a monitored scope. ``event_types`` is an array of the event IDs for
139139
events that may be fired from the scope. For example, the ID of a ``PY_START``
@@ -158,7 +158,35 @@ would typically correspond to a python function.
158158
execution is paused, such as when emulating a generator, the scope needs to
159159
be exited and re-entered.
160160
161-
162-
.. :c:function:: int PyMonitoring_ExitScope(void)
161+
The macros for *event_types* are:
162+
163+
.. c:namespace:: NULL
164+
165+
.. The table is here to make the docs searchable, and to allow automatic
166+
links to the identifiers.
167+
168+
================================================== =====================================
169+
Macro Event
170+
================================================== =====================================
171+
.. c:macro:: PY_MONITORING_EVENT_BRANCH :monitoring-event:`BRANCH`
172+
.. c:macro:: PY_MONITORING_EVENT_CALL :monitoring-event:`CALL`
173+
.. c:macro:: PY_MONITORING_EVENT_C_RAISE :monitoring-event:`C_RAISE`
174+
.. c:macro:: PY_MONITORING_EVENT_C_RETURN :monitoring-event:`C_RETURN`
175+
.. c:macro:: PY_MONITORING_EVENT_EXCEPTION_HANDLED :monitoring-event:`EXCEPTION_HANDLED`
176+
.. c:macro:: PY_MONITORING_EVENT_INSTRUCTION :monitoring-event:`INSTRUCTION`
177+
.. c:macro:: PY_MONITORING_EVENT_JUMP :monitoring-event:`JUMP`
178+
.. c:macro:: PY_MONITORING_EVENT_LINE :monitoring-event:`LINE`
179+
.. c:macro:: PY_MONITORING_EVENT_PY_RESUME :monitoring-event:`PY_RESUME`
180+
.. c:macro:: PY_MONITORING_EVENT_PY_RETURN :monitoring-event:`PY_RETURN`
181+
.. c:macro:: PY_MONITORING_EVENT_PY_START :monitoring-event:`PY_START`
182+
.. c:macro:: PY_MONITORING_EVENT_PY_THROW :monitoring-event:`PY_THROW`
183+
.. c:macro:: PY_MONITORING_EVENT_PY_UNWIND :monitoring-event:`PY_UNWIND`
184+
.. c:macro:: PY_MONITORING_EVENT_PY_YIELD :monitoring-event:`PY_YIELD`
185+
.. c:macro:: PY_MONITORING_EVENT_RAISE :monitoring-event:`RAISE`
186+
.. c:macro:: PY_MONITORING_EVENT_RERAISE :monitoring-event:`RERAISE`
187+
.. c:macro:: PY_MONITORING_EVENT_STOP_ITERATION :monitoring-event:`STOP_ITERATION`
188+
================================================== =====================================
189+
190+
.. c:function:: int PyMonitoring_ExitScope(void)
163191
164192
Exit the last scope that was entered with ``PyMonitoring_EnterScope``.

Doc/c-api/refcounting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ of Python objects.
6262
``NULL``, use :c:func:`Py_XINCREF`.
6363
6464
Do not expect this function to actually modify *o* in any way.
65-
For at least `some objects <https://peps.python.org/pep-0683/>`_,
65+
For at least :pep:`some objects <0683>`,
6666
this function has no effect.
6767
6868
.. versionchanged:: 3.12
@@ -130,7 +130,7 @@ of Python objects.
130130
use :c:func:`Py_XDECREF`.
131131
132132
Do not expect this function to actually modify *o* in any way.
133-
For at least `some objects <https://peps.python.org/pep-0683/>`_,
133+
For at least :pep:`some objects <683>`,
134134
this function has no effect.
135135
136136
.. warning::

Doc/c-api/type.rst

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,24 @@ Type Objects
264264
265265
.. versionadded:: 3.11
266266
267+
.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
268+
269+
Find the first superclass in *type*'s :term:`method resolution order` whose
270+
:c:macro:`Py_tp_token` token is equal to the given one.
271+
272+
* If found, set *\*result* to a new :term:`strong reference`
273+
to it and return ``1``.
274+
* If not found, set *\*result* to ``NULL`` and return ``0``.
275+
* On error, set *\*result* to ``NULL`` and return ``-1`` with an
276+
exception set.
277+
278+
The *result* argument may be ``NULL``, in which case *\*result* is not set.
279+
Use this if you need only the return value.
280+
281+
The *token* argument may not be ``NULL``.
282+
283+
.. versionadded:: 3.14
284+
267285
.. c:function:: int PyUnstable_Type_AssignVersionTag(PyTypeObject *type)
268286
269287
Attempt to assign a version tag to the given type.
@@ -488,6 +506,11 @@ The following functions and structs are used to create
488506
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
489507
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
490508
509+
An additional slot is supported that does not correspond to a
510+
:c:type:`!PyTypeObject` struct field:
511+
512+
* :c:data:`Py_tp_token`
513+
491514
The following “offset” fields cannot be set using :c:type:`PyType_Slot`:
492515
493516
* :c:member:`~PyTypeObject.tp_weaklistoffset`
@@ -538,4 +561,47 @@ The following functions and structs are used to create
538561
The desired value of the slot. In most cases, this is a pointer
539562
to a function.
540563
541-
Slots other than ``Py_tp_doc`` may not be ``NULL``.
564+
*pfunc* values may not be ``NULL``, except for the following slots:
565+
566+
* ``Py_tp_doc``
567+
* :c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC`
568+
rather than ``NULL``)
569+
570+
.. c:macro:: Py_tp_token
571+
572+
A :c:member:`~PyType_Slot.slot` that records a static memory layout ID
573+
for a class.
574+
575+
If the :c:type:`PyType_Spec` of the class is statically
576+
allocated, the token can be set to the spec using the special value
577+
:c:data:`Py_TP_USE_SPEC`:
578+
579+
.. code-block:: c
580+
581+
static PyType_Slot foo_slots[] = {
582+
{Py_tp_token, Py_TP_USE_SPEC},
583+
584+
It can also be set to an arbitrary pointer, but you must ensure that:
585+
586+
* The pointer outlives the class, so it's not reused for something else
587+
while the class exists.
588+
* It "belongs" to the extension module where the class lives, so it will not
589+
clash with other extensions.
590+
591+
Use :c:func:`PyType_GetBaseByToken` to check if a class's superclass has
592+
a given token -- that is, check whether the memory layout is compatible.
593+
594+
To get the token for a given class (without considering superclasses),
595+
use :c:func:`PyType_GetSlot` with ``Py_tp_token``.
596+
597+
.. versionadded:: 3.14
598+
599+
.. c:namespace:: NULL
600+
601+
.. c:macro:: Py_TP_USE_SPEC
602+
603+
Used as a value with :c:data:`Py_tp_token` to set the token to the
604+
class's :c:type:`PyType_Spec`.
605+
Expands to ``NULL``.
606+
607+
.. versionadded:: 3.14

Doc/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
('c:func', 'vsnprintf'),
133133
# Standard C types
134134
('c:type', 'FILE'),
135+
('c:type', 'int8_t'),
136+
('c:type', 'int16_t'),
135137
('c:type', 'int32_t'),
136138
('c:type', 'int64_t'),
137139
('c:type', 'intmax_t'),
@@ -141,6 +143,8 @@
141143
('c:type', 'size_t'),
142144
('c:type', 'ssize_t'),
143145
('c:type', 'time_t'),
146+
('c:type', 'uint8_t'),
147+
('c:type', 'uint16_t'),
144148
('c:type', 'uint32_t'),
145149
('c:type', 'uint64_t'),
146150
('c:type', 'uintmax_t'),
@@ -244,6 +248,7 @@
244248
('c:data', 'PyExc_OverflowError'),
245249
('c:data', 'PyExc_PermissionError'),
246250
('c:data', 'PyExc_ProcessLookupError'),
251+
('c:data', 'PyExc_PythonFinalizationError'),
247252
('c:data', 'PyExc_RecursionError'),
248253
('c:data', 'PyExc_ReferenceError'),
249254
('c:data', 'PyExc_RuntimeError'),

0 commit comments

Comments
 (0)