Skip to content

Commit c37b277

Browse files
authored
Merge branch 'main' into gh-151556
2 parents 3da4caa + 2ac1611 commit c37b277

157 files changed

Lines changed: 20438 additions & 2339 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.

.github/workflows/jit.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ jobs:
6464
include:
6565
- target: i686-pc-windows-msvc/msvc
6666
architecture: Win32
67-
runner: windows-2025-vs2026
67+
runner: windows-2025
6868
- target: x86_64-pc-windows-msvc/msvc
6969
architecture: x64
70-
runner: windows-2025-vs2026
70+
runner: windows-2025
7171
- target: aarch64-pc-windows-msvc/msvc
7272
architecture: ARM64
7373
runner: windows-11-arm
@@ -183,6 +183,9 @@ jobs:
183183
- name: JIT without optimizations (Debug)
184184
configure_flags: --enable-experimental-jit --with-pydebug
185185
test_env: "PYTHON_UOPS_OPTIMIZE=0"
186+
- name: JIT with stress testing (Debug)
187+
configure_flags: --enable-experimental-jit --with-pydebug
188+
test_env: "PYTHON_JIT_STRESS=1"
186189
- name: JIT with tail calling interpreter
187190
configure_flags: --enable-experimental-jit --with-tail-call-interp --with-pydebug
188191
use_clang: true

.github/workflows/reusable-windows-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
build:
1919
name: installer for ${{ inputs.arch }}
20-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025-vs2026' }}
20+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025' }}
2121
timeout-minutes: 60
2222
env:
2323
ARCH: ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
jobs:
2727
build:
2828
name: Build and test (${{ inputs.arch }}, ${{ inputs.interpreter }})
29-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025-vs2026' }}
29+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025' }}
3030
timeout-minutes: 60
3131
env:
3232
ARCH: ${{ inputs.arch }}

.readthedocs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ build:
1111
os: ubuntu-24.04
1212
tools:
1313
python: "3"
14+
apt_packages:
15+
- jq
1416

1517
jobs:
16-
post_checkout:
18+
post_system_dependencies:
1719
# https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html#skip-builds-based-on-conditions
1820
#
19-
# Cancel building pull requests when there aren't changes in the Doc
21+
# Cancel building pull requests when there are no changes in the Doc
2022
# directory or RTD configuration, or if we can't cleanly merge the base
2123
# branch.
2224
- |
2325
set -eEux;
2426
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ];
2527
then
26-
base_branch=main;
28+
base_branch=$(wget -qO- "https://api.github.com/repos/python/cpython/pulls/$READTHEDOCS_VERSION" | jq -er ".base.ref");
2729
git fetch --depth=50 origin $base_branch:origin-$base_branch;
2830
for attempt in $(seq 10);
2931
do

Doc/c-api/bytes.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,18 @@ Getters
384384
385385
Get the writer size.
386386
387+
The function does not invalidate pointers returned by
388+
:c:func:`PyBytesWriter_GetData`.
389+
387390
The function cannot fail.
388391
389392
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer)
390393
391394
Get the writer data: start of the internal buffer.
392395
393-
The pointer is valid until :c:func:`PyBytesWriter_Finish` or
394-
:c:func:`PyBytesWriter_Discard` is called on *writer*.
396+
The pointer remains valid until a :c:type:`PyBytesWriter` function other
397+
than :c:func:`PyBytesWriter_GetData` or :c:func:`PyBytesWriter_GetSize` is
398+
called on *writer*.
395399
396400
The function cannot fail.
397401

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/deprecations/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Deprecations
22
============
33

4-
.. include:: pending-removal-in-3.16.rst
5-
64
.. include:: pending-removal-in-3.17.rst
75

86
.. include:: pending-removal-in-3.18.rst
@@ -20,8 +18,6 @@ Deprecations
2018
C API deprecations
2119
------------------
2220

23-
.. include:: c-api-pending-removal-in-3.16.rst
24-
2521
.. include:: c-api-pending-removal-in-3.18.rst
2622

2723
.. include:: c-api-pending-removal-in-3.19.rst

Doc/extending/extending.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,8 @@ calling the Python callback functions from a C callback. Other uses are also
231231
imaginable.
232232

233233
Fortunately, the Python interpreter is easily called recursively, and there is a
234-
standard interface to call a Python function. (I won't dwell on how to call the
235-
Python parser with a particular string as input --- if you're interested, have a
236-
look at the implementation of the :option:`-c` command line option in
237-
:file:`Modules/main.c` from the Python source code.)
234+
standard interface to call a Python function. (If you're interested in how to call the
235+
Python parser with a particular string as input, see :ref:`veryhigh`.)
238236

239237
Calling a Python function is easy. First, the Python program must somehow pass
240238
you the Python function object. You should provide a function (or some other
@@ -641,7 +639,7 @@ and the object is freed.
641639

642640
An alternative strategy is called :dfn:`automatic garbage collection`.
643641
(Sometimes, reference counting is also referred to as a garbage collection
644-
strategy, hence my use of "automatic" to distinguish the two.) The big
642+
strategy, hence the use of "automatic" to distinguish the two.) The big
645643
advantage of automatic garbage collection is that the user doesn't need to call
646644
:c:func:`free` explicitly. (Another claimed advantage is an improvement in speed
647645
or memory usage --- this is no hard fact however.) The disadvantage is that for

Doc/glossary.rst

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,24 @@ Glossary
9696
:meth:`~object.__aexit__` methods. Introduced by :pep:`492`.
9797

9898
asynchronous generator
99-
A function which returns an :term:`asynchronous generator iterator`. It
100-
looks like a coroutine function defined with :keyword:`async def` except
101-
that it contains :keyword:`yield` expressions for producing a series of
102-
values usable in an :keyword:`async for` loop.
103-
104-
Usually refers to an asynchronous generator function, but may refer to an
105-
*asynchronous generator iterator* in some contexts. In cases where the
106-
intended meaning isn't clear, using the full terms avoids ambiguity.
99+
Informally used to mean either an :term:`asynchronous generator
100+
function` or an :term:`asynchronous generator iterator`, depending on
101+
context. The formal terms :term:`asynchronous generator function` and
102+
:term:`asynchronous generator iterator` are uncommon in practice;
103+
"asynchronous generator" alone is almost always sufficient.
104+
105+
asynchronous generator function
106+
A function which returns an :term:`asynchronous generator iterator`.
107+
It looks like a coroutine function defined with :keyword:`async def`
108+
except that it contains :keyword:`yield` expressions for producing a
109+
series of values usable in an :keyword:`async for` loop. See :pep:`525`.
107110

108111
An asynchronous generator function may contain :keyword:`await`
109112
expressions as well as :keyword:`async for`, and :keyword:`async with`
110113
statements.
111114

112115
asynchronous generator iterator
113-
An object created by an :term:`asynchronous generator` function.
116+
An object created by an :term:`asynchronous generator function`.
114117

115118
This is an :term:`asynchronous iterator` which when called using the
116119
:meth:`~object.__anext__` method returns an awaitable object which will execute
@@ -641,23 +644,33 @@ Glossary
641644
.. index:: single: generator
642645

643646
generator
644-
A function which returns a :term:`generator iterator`. It looks like a
645-
normal function except that it contains :keyword:`yield` expressions
646-
for producing a series of values usable in a for-loop or that can be
647-
retrieved one at a time with the :func:`next` function.
647+
Informally used to mean either a :term:`generator function` or a
648+
:term:`generator iterator`, depending on context. The formal terms
649+
:term:`generator function` and :term:`generator iterator` are uncommon
650+
in practice; "generator" alone is almost always sufficient.
648651

649-
Usually refers to a generator function, but may refer to a
650-
*generator iterator* in some contexts. In cases where the intended
651-
meaning isn't clear, using the full terms avoids ambiguity.
652+
.. index:: single: generator function
653+
654+
generator function
655+
A function which returns a :term:`generator` object. It looks like a
656+
normal function except that it contains :keyword:`yield` expressions
657+
for producing a series of values usable in a :keyword:`for`\-loop or
658+
that can be retrieved one at a time with the :func:`next` function.
659+
See :ref:`yieldexpr`.
652660

653661
generator iterator
654-
An object created by a :term:`generator` function.
662+
An object created by a :term:`generator function` or a
663+
:term:`generator expression`.
655664

656665
Each :keyword:`yield` temporarily suspends processing, remembering the
657-
execution state (including local variables and pending
658-
try-statements). When the *generator iterator* resumes, it picks up where
659-
it left off (in contrast to functions which start fresh on every
660-
invocation).
666+
execution state (including local variables and pending try-statements).
667+
When the *generator iterator* resumes, it picks up where it left off
668+
(in contrast to functions which start fresh on every invocation).
669+
670+
Generator iterators also implement the :meth:`~generator.send` method
671+
to send a value into the suspended generator, and the
672+
:meth:`~generator.throw` method to raise an exception at the point
673+
where the generator was paused. See :ref:`generator-methods`.
661674

662675
.. index:: single: generator expression
663676

0 commit comments

Comments
 (0)