Skip to content

Commit b5fab45

Browse files
committed
Merge remote-tracking branch 'origin/main' into gh-158195-unpin-type-lock
2 parents 5687320 + 19270d3 commit b5fab45

26 files changed

Lines changed: 530 additions & 101 deletions

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ Lib/test/test_*time.py @pganssle @StanFromIreland
432432
Modules/*zoneinfo* @pganssle @StanFromIreland
433433
Modules/*time* @pganssle @StanFromIreland
434434
Python/pytime.c @pganssle @StanFromIreland
435+
Python/_strptime.c @pganssle @StanFromIreland
435436

436437
# Dbm
437438
Doc/library/dbm.rst @corona10 @erlend-aasland @serhiy-storchaka

‎Doc/c-api/buffer.rst‎

Lines changed: 144 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,38 @@ The flags that control the logical structure of the memory are listed
284284
in decreasing order of complexity. Note that each flag contains all bits
285285
of the flags below it.
286286

287-
.. tabularcolumns:: |p{0.35\linewidth}|l|l|l|
288-
289-
+-----------------------------+-------+---------+------------+
290-
| Request | shape | strides | suboffsets |
291-
+=============================+=======+=========+============+
292-
| .. c:macro:: PyBUF_INDIRECT | yes | yes | if needed |
293-
+-----------------------------+-------+---------+------------+
294-
| .. c:macro:: PyBUF_STRIDES | yes | yes | NULL |
295-
+-----------------------------+-------+---------+------------+
296-
| .. c:macro:: PyBUF_ND | yes | NULL | NULL |
297-
+-----------------------------+-------+---------+------------+
298-
| .. c:macro:: PyBUF_SIMPLE | NULL | NULL | NULL |
299-
+-----------------------------+-------+---------+------------+
287+
.. stable-abi-note::
288+
289+
These values are available when compiling for the
290+
:ref:`Stable ABI <stable>` since version 3.11.
291+
292+
.. omit-stable-abi-notes::
293+
294+
.. list-table::
295+
:align: left
296+
:widths: auto
297+
:header-rows: 1
298+
299+
* - Request
300+
- shape
301+
- strides
302+
- suboffsets
303+
* - .. c:macro:: PyBUF_INDIRECT
304+
- yes
305+
- yes
306+
- if needed
307+
* - .. c:macro:: PyBUF_STRIDES
308+
- yes
309+
- yes
310+
- NULL
311+
* - .. c:macro:: PyBUF_ND
312+
- yes
313+
- NULL
314+
- NULL
315+
* - .. c:macro:: PyBUF_SIMPLE
316+
- NULL
317+
- NULL
318+
- NULL
300319

301320

302321
.. index:: contiguous, C-contiguous, Fortran contiguous
@@ -308,19 +327,43 @@ C or Fortran :term:`contiguity <contiguous>` can be explicitly requested,
308327
with and without stride information. Without stride information, the buffer
309328
must be C-contiguous.
310329

311-
.. tabularcolumns:: |p{0.35\linewidth}|l|l|l|l|
312-
313-
+-----------------------------------+-------+---------+------------+--------+
314-
| Request | shape | strides | suboffsets | contig |
315-
+===================================+=======+=========+============+========+
316-
| .. c:macro:: PyBUF_C_CONTIGUOUS | yes | yes | NULL | C |
317-
+-----------------------------------+-------+---------+------------+--------+
318-
| .. c:macro:: PyBUF_F_CONTIGUOUS | yes | yes | NULL | F |
319-
+-----------------------------------+-------+---------+------------+--------+
320-
| .. c:macro:: PyBUF_ANY_CONTIGUOUS | yes | yes | NULL | C or F |
321-
+-----------------------------------+-------+---------+------------+--------+
322-
| :c:macro:`PyBUF_ND` | yes | NULL | NULL | C |
323-
+-----------------------------------+-------+---------+------------+--------+
330+
.. stable-abi-note::
331+
332+
These values are available when compiling for the
333+
:ref:`Stable ABI <stable>` since version 3.11.
334+
335+
.. omit-stable-abi-notes::
336+
337+
.. list-table::
338+
:align: left
339+
:widths: auto
340+
:header-rows: 1
341+
342+
* - Request
343+
- shape
344+
- strides
345+
- suboffsets
346+
- contig
347+
* - .. c:macro:: PyBUF_C_CONTIGUOUS
348+
- yes
349+
- yes
350+
- NULL
351+
- C
352+
* - .. c:macro:: PyBUF_F_CONTIGUOUS
353+
- yes
354+
- yes
355+
- NULL
356+
- F
357+
* - .. c:macro:: PyBUF_ANY_CONTIGUOUS
358+
- yes
359+
- yes
360+
- NULL
361+
- C or F
362+
* - :c:macro:`PyBUF_ND`
363+
- yes
364+
- NULL
365+
- NULL
366+
- C
324367

325368

326369
compound requests
@@ -333,27 +376,81 @@ used combinations as single flags.
333376
In the following table *U* stands for undefined contiguity. The consumer would
334377
have to call :c:func:`PyBuffer_IsContiguous` to determine contiguity.
335378

336-
.. tabularcolumns:: |p{0.35\linewidth}|l|l|l|l|l|l|
337-
338-
+-------------------------------+-------+---------+------------+--------+----------+--------+
339-
| Request | shape | strides | suboffsets | contig | readonly | format |
340-
+===============================+=======+=========+============+========+==========+========+
341-
| .. c:macro:: PyBUF_FULL | yes | yes | if needed | U | 0 | yes |
342-
+-------------------------------+-------+---------+------------+--------+----------+--------+
343-
| .. c:macro:: PyBUF_FULL_RO | yes | yes | if needed | U | 1 or 0 | yes |
344-
+-------------------------------+-------+---------+------------+--------+----------+--------+
345-
| .. c:macro:: PyBUF_RECORDS | yes | yes | NULL | U | 0 | yes |
346-
+-------------------------------+-------+---------+------------+--------+----------+--------+
347-
| .. c:macro:: PyBUF_RECORDS_RO | yes | yes | NULL | U | 1 or 0 | yes |
348-
+-------------------------------+-------+---------+------------+--------+----------+--------+
349-
| .. c:macro:: PyBUF_STRIDED | yes | yes | NULL | U | 0 | NULL |
350-
+-------------------------------+-------+---------+------------+--------+----------+--------+
351-
| .. c:macro:: PyBUF_STRIDED_RO | yes | yes | NULL | U | 1 or 0 | NULL |
352-
+-------------------------------+-------+---------+------------+--------+----------+--------+
353-
| .. c:macro:: PyBUF_CONTIG | yes | NULL | NULL | C | 0 | NULL |
354-
+-------------------------------+-------+---------+------------+--------+----------+--------+
355-
| .. c:macro:: PyBUF_CONTIG_RO | yes | NULL | NULL | C | 1 or 0 | NULL |
356-
+-------------------------------+-------+---------+------------+--------+----------+--------+
379+
.. stable-abi-note::
380+
381+
These values are available when compiling for the
382+
:ref:`Stable ABI <stable>` since version 3.11.
383+
384+
.. omit-stable-abi-notes::
385+
386+
.. list-table::
387+
:align: left
388+
:widths: auto
389+
:header-rows: 1
390+
391+
* - Request
392+
- shape
393+
- strides
394+
- suboffsets
395+
- contig
396+
- readonly
397+
- format
398+
* - .. c:macro:: PyBUF_FULL
399+
- yes
400+
- yes
401+
- if needed
402+
- U
403+
- 0
404+
- yes
405+
* - .. c:macro:: PyBUF_FULL_RO
406+
- yes
407+
- yes
408+
- if needed
409+
- U
410+
- 1 or 0
411+
- yes
412+
* - .. c:macro:: PyBUF_RECORDS
413+
- yes
414+
- yes
415+
- NULL
416+
- U
417+
- 0
418+
- yes
419+
* - .. c:macro:: PyBUF_RECORDS_RO
420+
- yes
421+
- yes
422+
- NULL
423+
- U
424+
- 1 or 0
425+
- yes
426+
* - .. c:macro:: PyBUF_STRIDED
427+
- yes
428+
- yes
429+
- NULL
430+
- U
431+
- 0
432+
- NULL
433+
* - .. c:macro:: PyBUF_STRIDED_RO
434+
- yes
435+
- yes
436+
- NULL
437+
- U
438+
- 1 or 0
439+
- NULL
440+
* - .. c:macro:: PyBUF_CONTIG
441+
- yes
442+
- NULL
443+
- NULL
444+
- C
445+
- 0
446+
- NULL
447+
* - .. c:macro:: PyBUF_CONTIG_RO
448+
- yes
449+
- NULL
450+
- NULL
451+
- C
452+
- 1 or 0
453+
- NULL
357454

358455

359456
Complex arrays

‎Doc/c-api/gcsupport.rst‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
251251
to the handler. The *visit* function must not be called with a ``NULL``
252252
object argument. If *visit* returns a non-zero value, that value should be
253253
returned immediately.
254+
Otherwise, return zero.
254255
255256
A typical :c:member:`!tp_traverse` function calls the :c:func:`Py_VISIT`
256257
convenience macro on each of the instance's members that are Python
@@ -317,6 +318,14 @@ The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
317318
For a list of safe functions, see a
318319
:ref:`separate section <duringgc-functions>` below.
319320
321+
If an error occurs during traversal, ignore it and return 0.
322+
If ``tp_traverse`` fails to visit some strong references, garbage reference
323+
cycles involving the skipped references will not be reliably broken,
324+
but correctness won't be affected.
325+
For example, if traversal requires a lock that cannot be acquired promptly,
326+
skip the traversal.
327+
The garbage collector will visit your object again in a future pass.
328+
320329
.. note::
321330
322331
The :c:func:`Py_VISIT` call may be skipped for those members that provably
@@ -362,7 +371,7 @@ implementation must name its arguments exactly *visit* and *arg*:
362371
This corresponds roughly to::
363372
364373
#define Py_VISIT(o) \
365-
if (op) { \
374+
if (o) { \
366375
int visit_result = visit(o, arg); \
367376
if (visit_result != 0) { \
368377
return visit_result; \

‎Doc/c-api/long.rst‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,17 +535,24 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
535535
536536
.. c:namespace:: NULL
537537
538-
============================================= ======
539-
Flag Value
540-
============================================= ======
541-
.. c:macro:: Py_ASNATIVEBYTES_DEFAULTS ``-1``
542-
.. c:macro:: Py_ASNATIVEBYTES_BIG_ENDIAN ``0``
543-
.. c:macro:: Py_ASNATIVEBYTES_LITTLE_ENDIAN ``1``
544-
.. c:macro:: Py_ASNATIVEBYTES_NATIVE_ENDIAN ``3``
545-
.. c:macro:: Py_ASNATIVEBYTES_UNSIGNED_BUFFER ``4``
546-
.. c:macro:: Py_ASNATIVEBYTES_REJECT_NEGATIVE ``8``
547-
.. c:macro:: Py_ASNATIVEBYTES_ALLOW_INDEX ``16``
548-
============================================= ======
538+
.. stable-abi-note::
539+
540+
These values are available when compiling for the
541+
:ref:`Stable ABI <stable>` since version 3.14.
542+
543+
.. omit-stable-abi-notes::
544+
545+
============================================= ======
546+
Flag Value
547+
============================================= ======
548+
.. c:macro:: Py_ASNATIVEBYTES_DEFAULTS ``-1``
549+
.. c:macro:: Py_ASNATIVEBYTES_BIG_ENDIAN ``0``
550+
.. c:macro:: Py_ASNATIVEBYTES_LITTLE_ENDIAN ``1``
551+
.. c:macro:: Py_ASNATIVEBYTES_NATIVE_ENDIAN ``3``
552+
.. c:macro:: Py_ASNATIVEBYTES_UNSIGNED_BUFFER ``4``
553+
.. c:macro:: Py_ASNATIVEBYTES_REJECT_NEGATIVE ``8``
554+
.. c:macro:: Py_ASNATIVEBYTES_ALLOW_INDEX ``16``
555+
============================================= ======
549556
550557
Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian
551558
flags. Passing ``2`` is reserved.

‎Doc/c-api/structures.rst‎

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -812,29 +812,77 @@ If that is not possible, an exception such as :exc:`TypeError` or
812812
Unless marked (D), attributes defined this way cannot be deleted
813813
using e.g. :keyword:`del` or :py:func:`delattr`.
814814
815-
================================ ============================= ======================
816-
Macro name C type Python type
817-
================================ ============================= ======================
818-
.. c:macro:: Py_T_BYTE :c:expr:`char` :py:class:`int`
819-
.. c:macro:: Py_T_SHORT :c:expr:`short` :py:class:`int`
820-
.. c:macro:: Py_T_INT :c:expr:`int` :py:class:`int`
821-
.. c:macro:: Py_T_LONG :c:expr:`long` :py:class:`int`
822-
.. c:macro:: Py_T_LONGLONG :c:expr:`long long` :py:class:`int`
823-
.. c:macro:: Py_T_UBYTE :c:expr:`unsigned char` :py:class:`int`
824-
.. c:macro:: Py_T_UINT :c:expr:`unsigned int` :py:class:`int`
825-
.. c:macro:: Py_T_USHORT :c:expr:`unsigned short` :py:class:`int`
826-
.. c:macro:: Py_T_ULONG :c:expr:`unsigned long` :py:class:`int`
827-
.. c:macro:: Py_T_ULONGLONG :c:expr:`unsigned long long` :py:class:`int`
828-
.. c:macro:: Py_T_PYSSIZET :c:expr:`Py_ssize_t` :py:class:`int`
829-
.. c:macro:: Py_T_FLOAT :c:expr:`float` :py:class:`float`
830-
.. c:macro:: Py_T_DOUBLE :c:expr:`double` :py:class:`float`
831-
.. c:macro:: Py_T_BOOL :c:expr:`char` :py:class:`bool`
832-
(written as 0 or 1)
833-
.. c:macro:: Py_T_STRING :c:expr:`const char *` (*) :py:class:`str` (RO)
834-
.. c:macro:: Py_T_STRING_INPLACE :c:expr:`const char[]` (*) :py:class:`str` (RO)
835-
.. c:macro:: Py_T_CHAR :c:expr:`char` (0-127) :py:class:`str` (**)
836-
.. c:macro:: Py_T_OBJECT_EX :c:expr:`PyObject *` :py:class:`object` (D)
837-
================================ ============================= ======================
815+
.. stable-abi-note::
816+
817+
These values are available when compiling for the
818+
:ref:`Stable ABI <stable>` since version 3.12.
819+
820+
.. omit-stable-abi-notes::
821+
822+
.. list-table::
823+
:align: left
824+
:widths: auto
825+
:header-rows: 1
826+
827+
* - Macro name
828+
- C type
829+
- Python type
830+
* - .. c:macro:: Py_T_BYTE
831+
- :c:expr:`char`
832+
- :py:class:`int`
833+
* - .. c:macro:: Py_T_SHORT
834+
- :c:expr:`short`
835+
- :py:class:`int`
836+
* - .. c:macro:: Py_T_INT
837+
- :c:expr:`int`
838+
- :py:class:`int`
839+
* - .. c:macro:: Py_T_LONG
840+
- :c:expr:`long`
841+
- :py:class:`int`
842+
* - .. c:macro:: Py_T_LONGLONG
843+
- :c:expr:`long long`
844+
- :py:class:`int`
845+
* - .. c:macro:: Py_T_UBYTE
846+
- :c:expr:`unsigned char`
847+
- :py:class:`int`
848+
* - .. c:macro:: Py_T_UINT
849+
- :c:expr:`unsigned int`
850+
- :py:class:`int`
851+
* - .. c:macro:: Py_T_USHORT
852+
- :c:expr:`unsigned short`
853+
- :py:class:`int`
854+
* - .. c:macro:: Py_T_ULONG
855+
- :c:expr:`unsigned long`
856+
- :py:class:`int`
857+
* - .. c:macro:: Py_T_ULONGLONG
858+
- :c:expr:`unsigned long long`
859+
- :py:class:`int`
860+
* - .. c:macro:: Py_T_PYSSIZET
861+
- :c:expr:`Py_ssize_t`
862+
- :py:class:`int`
863+
* - .. c:macro:: Py_T_FLOAT
864+
- :c:expr:`float`
865+
- :py:class:`float`
866+
* - .. c:macro:: Py_T_DOUBLE
867+
- :c:expr:`double`
868+
- :py:class:`float`
869+
* - .. c:macro:: Py_T_BOOL
870+
- :c:expr:`char` (written as 0 or 1)
871+
- :py:class:`bool`
872+
* - .. c:macro:: Py_T_STRING
873+
- :c:expr:`const char *` (*)
874+
- :py:class:`str` (RO)
875+
* - .. c:macro:: Py_T_STRING_INPLACE
876+
- :c:expr:`const char[]` (*)
877+
- :py:class:`str` (RO)
878+
* - .. c:macro:: Py_T_CHAR
879+
- :c:expr:`char` (0-127)
880+
- :py:class:`str` (**)
881+
* - .. c:macro:: Py_T_OBJECT_EX
882+
- :c:expr:`PyObject *`
883+
- :py:class:`object` (D)
884+
885+
..
838886
839887
(*): Zero-terminated, UTF8-encoded C string.
840888
With :c:macro:`!Py_T_STRING` the C representation is a pointer;

0 commit comments

Comments
 (0)