Merge branch 'main' into spi-cache · python/cpython@72cd269 · GitHub
Skip to content

Commit 72cd269

Browse files
authored
Merge branch 'main' into spi-cache
2 parents aa825d2 + 8a284e1 commit 72cd269

59 files changed

Lines changed: 661 additions & 673 deletions

Some content is hidden

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

Doc/c-api/code.rst

Lines changed: 2 additions & 2 deletions

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/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/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/general.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ releases.
311311
The latest stable releases can always be found on the `Python download page
312312
<https://www.python.org/downloads/>`_. There are two production-ready versions
313313
of Python: 2.x and 3.x. The recommended version is 3.x, which is supported by
314-
most widely used libraries. Although 2.x is still widely used, `it is not
315-
maintained anymore <https://peps.python.org/pep-0373/>`_.
314+
most widely used libraries. Although 2.x is still widely used, :pep:`it is not
315+
maintained anymore <0373>`.
316316

317317
How many people are using Python?
318318
---------------------------------

Doc/library/ast.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,8 +2033,7 @@ Function and class definitions
20332033
* ``name`` is a raw string for the class name
20342034
* ``bases`` is a list of nodes for explicitly specified base classes.
20352035
* ``keywords`` is a list of :class:`.keyword` nodes, principally for 'metaclass'.
2036-
Other keywords will be passed to the metaclass, as per `PEP-3115
2037-
<https://peps.python.org/pep-3115/>`_.
2036+
Other keywords will be passed to the metaclass, as per :pep:`3115`.
20382037
* ``body`` is a list of nodes representing the code within the class
20392038
definition.
20402039
* ``decorator_list`` is a list of nodes, as in :class:`FunctionDef`.

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ The :mod:`functools` module defines the following functions:
218218
cache. See :ref:`faq-cache-method-calls`
219219

220220
An `LRU (least recently used) cache
221-
<https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)>`_
221+
<https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_(LRU)>`_
222222
works best when the most recent calls are the best predictors of upcoming
223223
calls (for example, the most popular articles on a news server tend to
224224
change each day). The cache's size limit assures that the cache does not

Doc/library/sqlite3.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -525,21 +525,20 @@ Module constants
525525
The mappings from SQLite threading modes to DB-API 2.0 threadsafety levels
526526
are as follows:
527527

528-
+------------------+-----------------+----------------------+-------------------------------+
529-
| SQLite threading | `threadsafety`_ | `SQLITE_THREADSAFE`_ | DB-API 2.0 meaning |
530-
| mode | | | |
531-
+==================+=================+======================+===============================+
532-
| single-thread | 0 | 0 | Threads may not share the |
533-
| | | | module |
534-
+------------------+-----------------+----------------------+-------------------------------+
535-
| multi-thread | 1 | 2 | Threads may share the module, |
536-
| | | | but not connections |
537-
+------------------+-----------------+----------------------+-------------------------------+
538-
| serialized | 3 | 1 | Threads may share the module, |
539-
| | | | connections and cursors |
540-
+------------------+-----------------+----------------------+-------------------------------+
541-
542-
.. _threadsafety: https://peps.python.org/pep-0249/#threadsafety
528+
+------------------+----------------------+----------------------+-------------------------------+
529+
| SQLite threading | :pep:`threadsafety | `SQLITE_THREADSAFE`_ | DB-API 2.0 meaning |
530+
| mode | <0249#threadsafety>` | | |
531+
+==================+======================+======================+===============================+
532+
| single-thread | 0 | 0 | Threads may not share the |
533+
| | | | module |
534+
+------------------+----------------------+----------------------+-------------------------------+
535+
| multi-thread | 1 | 2 | Threads may share the module, |
536+
| | | | but not connections |
537+
+------------------+----------------------+----------------------+-------------------------------+
538+
| serialized | 3 | 1 | Threads may share the module, |
539+
| | | | connections and cursors |
540+
+------------------+----------------------+----------------------+-------------------------------+
541+
543542
.. _SQLITE_THREADSAFE: https://sqlite.org/compile.html#threadsafe
544543

545544
.. versionchanged:: 3.11

Doc/library/ssl.rst

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)