Skip to content

Commit 21ac917

Browse files
authored
Merge branch 'main' into pythongh-151436
2 parents 1348756 + eff805b commit 21ac917

128 files changed

Lines changed: 996 additions & 319 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
root = true
22

3-
[*.{py,c,cpp,h,js,rst,md,yml,yaml,gram}]
3+
[*.{py,c,cpp,h,js,rst,md,yml,yaml,toml,gram}]
44
trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
77

8-
[*.{py,c,cpp,h,gram}]
8+
[*.{py,c,cpp,h,toml,gram}]
99
indent_size = 4
1010

1111
[*.rst]

.github/workflows/reusable-san.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ jobs:
8686
run: >-
8787
./python -m test
8888
${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }}
89-
-j4 -W
89+
-j4 -W --timeout=900 --slowest
9090
- name: Parallel tests
9191
if: >-
9292
inputs.sanitizer == 'TSan'
9393
&& fromJSON(inputs.free-threading)
94-
run: ./python -m test --tsan-parallel --parallel-threads=4 -j4 -W
94+
run: ./python -m test --tsan-parallel --parallel-threads=4 -j4 -W --timeout=600 --slowest
9595
- name: Display logs
9696
if: always()
9797
run: find "${GITHUB_WORKSPACE}" -name 'san_log.*' | xargs head -n 1000

.pre-commit-config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: e05c5c0818279e5ac248ac9e954431ba58865e61 # frozen: v0.15.7
3+
rev: 3b3f7c3f57fe9925356faf5fe6230835138be230 # frozen: v0.15.17
44
hooks:
55
- id: ruff-check
66
name: Run Ruff (lint) on Platforms/Apple/
@@ -10,6 +10,11 @@ repos:
1010
name: Run Ruff (lint) on Doc/
1111
args: [--exit-non-zero-on-fix]
1212
files: ^Doc/
13+
- id: ruff-check
14+
name: Run Ruff (lint) on Lib/
15+
args: [--exit-non-zero-on-fix]
16+
files: ^Lib/
17+
exclude: ^Lib/test/
1318
- id: ruff-check
1419
name: Run Ruff (lint) on Lib/test/
1520
args: [--exit-non-zero-on-fix]
@@ -18,6 +23,11 @@ repos:
1823
name: Run Ruff (lint) on Platforms/WASI/
1924
args: [--exit-non-zero-on-fix, --config=Platforms/WASI/.ruff.toml]
2025
files: ^Platforms/WASI/
26+
- id: ruff-check
27+
name: Run Ruff (lint) on Tools/
28+
args: [--exit-non-zero-on-fix]
29+
files: ^Tools/
30+
exclude: ^Tools/(build|clinic|i18n|peg_generator|wasm)/
2131
- id: ruff-check
2232
name: Run Ruff (lint) on Tools/build/
2333
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]

Doc/c-api/init_config.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ Some options are read from the :mod:`sys` attributes. For example, the option
623623
624624
.. versionadded:: 3.14
625625
626+
.. versionchanged:: next
627+
The function now replaces :data:`sys.flags` (create a new object),
628+
instead of modifying :data:`sys.flags` in-place.
629+
626630
627631
.. _pyconfig_api:
628632

Doc/c-api/type.rst

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,10 @@ but need extra remarks for use as slots:
563563
:c:member:`Slot ID <PySlot.sl_id>` for the name of the type,
564564
used to set :c:member:`PyTypeObject.tp_name`.
565565
566-
This slot (or :c:func:`PyType_Spec.name`) is required to create a type.
566+
This slot (or :c:member:`PyType_Spec.name`) is required to create a type.
567567
568568
This may not be used in :c:member:`PyType_Spec.slots`.
569-
Use :c:func:`PyType_Spec.name` instead.
569+
Use :c:member:`PyType_Spec.name` instead.
570570
571571
.. impl-detail::
572572
@@ -585,7 +585,7 @@ but need extra remarks for use as slots:
585585
The value must be positive.
586586
587587
This may not be used in :c:member:`PyType_Spec.slots`.
588-
Use :c:func:`PyType_Spec.basicsize` instead.
588+
Use :c:member:`PyType_Spec.basicsize` instead.
589589
590590
This slot may not be used with :c:func:`PyType_GetSlot`.
591591
Use :c:member:`PyTypeObject.tp_basicsize` instead if needed, but be aware
@@ -616,7 +616,7 @@ but need extra remarks for use as slots:
616616
:c:macro:`!Py_tp_extra_basicsize` is an error.
617617
618618
This may not be used in :c:member:`PyType_Spec.slots`.
619-
Use negative :c:func:`PyType_Spec.basicsize` instead.
619+
Use negative :c:member:`PyType_Spec.basicsize` instead.
620620
621621
This slot may not be used with :c:func:`PyType_GetSlot`.
622622
@@ -648,7 +648,7 @@ but need extra remarks for use as slots:
648648
- With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag.
649649
650650
This may not be used in :c:member:`PyType_Spec.slots`.
651-
Use :c:func:`PyType_Spec.itemsize` instead.
651+
Use :c:member:`PyType_Spec.itemsize` instead.
652652
653653
This slot may not be used with :c:func:`PyType_GetSlot`.
654654
@@ -663,13 +663,44 @@ but need extra remarks for use as slots:
663663
:c:func:`PyType_FromSpecWithBases` sets it automatically.
664664
665665
This may not be used in :c:member:`PyType_Spec.slots`.
666-
Use negative :c:func:`PyType_Spec.basicsize` instead.
666+
Use negative :c:member:`PyType_Spec.basicsize` instead.
667667
668668
This slot may not be used with :c:func:`PyType_GetSlot`.
669669
Use :c:func:`PyType_GetFlags` instead.
670670
671671
.. versionadded:: 3.15
672672
673+
.. c:macro:: Py_tp_bases
674+
675+
:c:member:`Slot ID <PySlot.sl_id>` for type flags, used to set
676+
:c:member:`PyTypeObject.tp_bases`.
677+
678+
The slot can be set to a tuple of type objects which the newly created
679+
type should inherit from, like the "positional arguments" of
680+
a Python :ref:`class definition <class>`.
681+
682+
Alternately, the slot can be set to a single type object to specify
683+
a single base.
684+
The effect is the same as specifying a one-element tuple.
685+
686+
.. versionchanged:: 3.15
687+
688+
Previously, :c:macro:`!Py_tp_bases` required a tuple of types.
689+
690+
.. c:macro:: Py_tp_base
691+
692+
Equivalent to :c:macro:`Py_tp_bases` (with ``s`` at the end).
693+
If both are specified, :c:macro:`!Py_tp_bases` takes priority and
694+
this slot is ignored.
695+
696+
.. versionchanged:: 3.15
697+
698+
Previously, :c:macro:`!Py_tp_base` required a single type, not a tuple.
699+
700+
.. soft-deprecated:: 3.15
701+
702+
When not targetting older Python versions, pefer :c:macro:`!Py_tp_bases`.
703+
673704
The following slots do not correspond to public fields in the
674705
underlying structures:
675706

Doc/c-api/typeobj.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,12 +1936,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
19361936

19371937
.. c:member:: PyTypeObject* PyTypeObject.tp_base
19381938
1939-
.. corresponding-type-slot:: Py_tp_base
1940-
19411939
An optional pointer to a base type from which type properties are inherited. At
19421940
this level, only single inheritance is supported; multiple inheritance require
19431941
dynamically creating a type object by calling the metatype.
19441942

1943+
For the corresponding slot ID, see :c:macro:`Py_tp_base`.
1944+
19451945
.. note::
19461946

19471947
.. from Modules/xxmodule.c
@@ -2253,17 +2253,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
22532253

22542254
.. c:member:: PyObject* PyTypeObject.tp_bases
22552255
2256-
.. corresponding-type-slot:: Py_tp_bases
2257-
22582256
Tuple of base types.
22592257

22602258
This field should be set to ``NULL`` and treated as read-only.
22612259
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.
22622260

2263-
For dynamically created classes, the :c:data:`Py_tp_bases`
2264-
:c:type:`slot <PyType_Slot>` can be used instead of the *bases* argument
2265-
of :c:func:`PyType_FromSpecWithBases`.
2266-
The argument form is preferred.
2261+
For the corresponding slot ID, see :c:macro:`Py_tp_bases`.
22672262

22682263
.. warning::
22692264

Doc/library/enum.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ Data types
629629
>>> white in purple
630630
False
631631

632-
.. method:: __iter__(self):
632+
.. method:: __iter__(self)
633633

634634
Returns all contained non-alias members::
635635

@@ -640,7 +640,7 @@ Data types
640640

641641
.. versionadded:: 3.11
642642

643-
.. method:: __len__(self):
643+
.. method:: __len__(self)
644644

645645
Returns number of members in flag::
646646

@@ -651,7 +651,7 @@ Data types
651651

652652
.. versionadded:: 3.11
653653

654-
.. method:: __bool__(self):
654+
.. method:: __bool__(self)
655655

656656
Returns *True* if any members in flag, *False* otherwise::
657657

@@ -688,7 +688,7 @@ Data types
688688
>>> purple ^ Color.GREEN
689689
<Color.RED|GREEN|BLUE: 7>
690690

691-
.. method:: __invert__(self):
691+
.. method:: __invert__(self)
692692

693693
Returns all the flags in *type(self)* that are not in *self*::
694694

Doc/library/mimetypes.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ the information :func:`init` sets up.
3939
(e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use
4040
as a :mailheader:`Content-Encoding` header, **not** as a
4141
:mailheader:`Content-Transfer-Encoding` header. The mappings are table driven.
42-
Encoding suffixes are case sensitive; type suffixes are first tried case
43-
sensitively, then case insensitively.
42+
Encoding suffixes are case-sensitive. Suffix mappings and type suffixes are
43+
first tried case-sensitively, then case-insensitively.
4444

4545
The optional *strict* argument is a flag specifying whether the list of known MIME types
4646
is limited to only the official types `registered with IANA
@@ -131,6 +131,8 @@ behavior of the module.
131131
is already known the extension will be added to the list of known extensions.
132132
Valid extensions are empty or start with a ``'.'``.
133133

134+
Registered lower-case extensions are matched case-insensitively.
135+
134136
When *strict* is ``True`` (the default), the mapping will be added to the
135137
official MIME types, otherwise to the non-standard ones.
136138

@@ -312,6 +314,8 @@ than one MIME-type database; it provides an interface similar to the one of the
312314
extension is already known, the new type will replace the old one. When the type
313315
is already known the extension will be added to the list of known extensions.
314316

317+
Registered lower-case extensions are matched case-insensitively.
318+
315319
When *strict* is ``True`` (the default), the mapping will be added to the
316320
official MIME types, otherwise to the non-standard ones.
317321

Doc/library/unittest.mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,7 @@ Alternatively you can just use ``vars(my_mock)`` (instance members) and
25392539
mock_open
25402540
~~~~~~~~~
25412541

2542-
.. function:: mock_open(mock=None, read_data=None)
2542+
.. function:: mock_open(mock=None, read_data='')
25432543

25442544
A helper function to create a mock to replace the use of :func:`open`. It works
25452545
for :func:`open` called directly or used as a context manager.

Doc/library/warnings.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,28 @@ Available Context Managers
626626
If the *record* argument is :const:`False` (the default) the context manager
627627
returns :class:`None` on entry. If *record* is :const:`True`, a list is
628628
returned that is progressively populated with objects as seen by a custom
629-
:func:`showwarning` function (which also suppresses output to ``sys.stdout``).
630-
Each object in the list has attributes with the same names as the arguments to
631-
:func:`showwarning`.
629+
:func:`showwarning` function (which also suppresses output to ``sys.stderr``).
630+
Each object in the list is guaranteed to have the following attributes:
631+
632+
- ``message``: the warning message (an instance of :exc:`Warning`)
633+
- ``category``: the warning category (a subclass of :exc:`Warning`)
634+
- ``filename``: the file name where the warning occurred (:class:`str`)
635+
- ``lineno``: the line number in the file (:class:`int`)
636+
- ``file``: the file object used for output (if any), or ``None``
637+
- ``line``: the line of source code (if available), or ``None``
638+
- ``source``: the original object that generated the warning (if
639+
available), or ``None``
640+
- ``module``: the module name where the warning occurred
641+
(:class:`str`), or ``None``
642+
643+
.. versionchanged:: 3.6
644+
The ``source`` attribute was added.
645+
646+
.. versionchanged:: 3.15
647+
The ``module`` attribute was added.
648+
649+
The type of these objects is not specified and may change; only the
650+
presence of these attributes is guaranteed.
632651

633652
The *module* argument takes a module that will be used instead of the
634653
module returned when you import :mod:`!warnings` whose filter will be

0 commit comments

Comments
 (0)