Skip to content

Commit 803d703

Browse files
committed
Merge 'origin/main' into pythongh-127266-type-slots-ts
2 parents caf6554 + 39ee468 commit 803d703

File tree

548 files changed

+25286
-8038
lines changed

Some content is hidden

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

548 files changed

+25286
-8038
lines changed

.azure-pipelines/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
trigger: ['main', '3.13', '3.12', '3.11', '3.10', '3.9', '3.8']
1+
trigger: ['main', '3.*']
22

33
jobs:
44
- job: Prebuild

.editorconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
root = true
22

3-
[*.{py,c,cpp,h,js,rst,md,yml}]
3+
[*.{py,c,cpp,h,js,rst,md,yml,yaml}]
44
trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
@@ -11,5 +11,5 @@ indent_size = 4
1111
[*.rst]
1212
indent_size = 3
1313

14-
[*.{js,yml}]
14+
[*.{js,yml,yaml}]
1515
indent_size = 2

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Python/ast_opt.c @isidentical @eclips4
188188
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
189189
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
190190
Lib/ast.py @isidentical @JelleZijlstra @eclips4
191+
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4
191192
Lib/test/test_ast/ @eclips4
192193

193194
# Mock

.github/PULL_REQUEST_TEMPLATE.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Please read this comment in its entirety. It's quite important.
77
It should be in the following format:
88
99
```
10-
gh-NNNNN: Summary of the changes made
10+
gh-NNNNNN: Summary of the changes made
1111
```
1212
13-
Where: gh-NNNNN refers to the GitHub issue number.
13+
Where: gh-NNNNNN refers to the GitHub issue number.
1414
1515
Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue.
1616
@@ -20,11 +20,11 @@ If this is a backport PR (PR made against branches other than `main`),
2020
please ensure that the PR title is in the following format:
2121
2222
```
23-
[X.Y] <title from the original PR> (GH-NNNN)
23+
[X.Y] <title from the original PR> (GH-NNNNNN)
2424
```
2525
26-
Where: [X.Y] is the branch name, e.g. [3.6].
26+
Where: [X.Y] is the branch name, for example: [3.13].
2727
28-
GH-NNNN refers to the PR number from `main`.
28+
GH-NNNNNN refers to the PR number from `main`.
2929
3030
-->

.github/actionlint.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
self-hosted-runner:
2-
labels: ["windows-aarch64"]
2+
# Pending https://github.com/rhysd/actionlint/issues/533
3+
labels: ["windows-11-arm"]
34

45
config-variables: null
56

.github/workflows/build.yml

+5-13
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,18 @@ jobs:
156156
strategy:
157157
fail-fast: false
158158
matrix:
159-
os:
160-
- windows-latest
161159
arch:
162160
- x64
161+
- Win32
162+
- arm64
163163
free-threading:
164164
- false
165165
- true
166-
include:
167-
- os: windows-latest # FIXME(diegorusso): change to os: windows-aarch64
168-
arch: arm64
169-
free-threading: false
170-
- os: windows-latest # FIXME(diegorusso): change to os: windows-aarch64
171-
arch: arm64
172-
free-threading: true
173-
- os: windows-latest
174-
arch: Win32
175-
free-threading: false
166+
exclude:
167+
# Skip Win32 on free-threaded builds
168+
- { arch: Win32, free-threading: true }
176169
uses: ./.github/workflows/reusable-windows.yml
177170
with:
178-
os: ${{ matrix.os }}
179171
arch: ${{ matrix.arch }}
180172
free-threading: ${{ matrix.free-threading }}
181173

.github/workflows/jit.yml

+5-12
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
runner: windows-latest
7575
- target: aarch64-pc-windows-msvc/msvc
7676
architecture: ARM64
77-
runner: windows-latest
77+
runner: windows-11-arm
7878
- target: x86_64-apple-darwin/clang
7979
architecture: x86_64
8080
runner: macos-13
@@ -95,25 +95,18 @@ jobs:
9595
with:
9696
python-version: '3.11'
9797

98-
- name: Native Windows
99-
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
98+
- name: Windows
99+
if: runner.os == 'Windows'
100100
run: |
101101
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
102102
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
103103
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
104104
105-
# No tests (yet):
106-
- name: Emulated Windows
107-
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
108-
run: |
109-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
110-
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
111-
112105
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
113106
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
114107
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
115108
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
116-
- name: Native macOS
109+
- name: macOS
117110
if: runner.os == 'macOS'
118111
run: |
119112
brew update
@@ -124,7 +117,7 @@ jobs:
124117
make all --jobs 4
125118
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
126119
127-
- name: Native Linux
120+
- name: Linux
128121
if: runner.os == 'Linux'
129122
run: |
130123
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}

.github/workflows/mypy.yml

+1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ jobs:
5959
cache: pip
6060
cache-dependency-path: Tools/requirements-dev.txt
6161
- run: pip install -r Tools/requirements-dev.txt
62+
- run: python3 Misc/mypy/make_symlinks.py --symlink
6263
- run: mypy --config-file ${{ matrix.target }}/mypy.ini

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

+1-1
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: windows-latest
20+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
2121
timeout-minutes: 60
2222
env:
2323
ARCH: ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Reusable Windows
33
on:
44
workflow_call:
55
inputs:
6-
os:
7-
description: OS to run on
8-
required: true
9-
type: string
106
arch:
117
description: CPU architecture
128
required: true
@@ -24,8 +20,8 @@ env:
2420
2521
jobs:
2622
build:
27-
name: ${{ inputs.arch == 'arm64' && 'build' || 'build and test' }} (${{ inputs.arch }})
28-
runs-on: ${{ inputs.os }}
23+
name: Build and test (${{ inputs.arch }})
24+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
2925
timeout-minutes: 60
3026
env:
3127
ARCH: ${{ inputs.arch }}
@@ -43,11 +39,9 @@ jobs:
4339
-p "${ARCH}"
4440
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
4541
shell: bash
46-
- name: Display build info # FIXME(diegorusso): remove the `if`
47-
if: inputs.arch != 'arm64'
42+
- name: Display build info
4843
run: .\\python.bat -m test.pythoninfo
49-
- name: Tests # FIXME(diegorusso): remove the `if`
50-
if: inputs.arch != 'arm64'
44+
- name: Tests
5145
run: >-
5246
.\\PCbuild\\rt.bat
5347
-p "${ARCH}"

.github/workflows/tail-call.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- aarch64-unknown-linux-gnu/gcc
4646
- free-threading
4747
llvm:
48-
- 19
48+
- 20
4949
include:
5050
# - target: i686-pc-windows-msvc/msvc
5151
# architecture: Win32
@@ -83,9 +83,9 @@ jobs:
8383
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
8484
shell: cmd
8585
run: |
86-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.5
86+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
8787
set PlatformToolset=clangcl
88-
set LLVMToolsVersion=${{ matrix.llvm }}.1.5
88+
set LLVMToolsVersion=${{ matrix.llvm }}.1.0
8989
set LLVMInstallDir=C:\Program Files\LLVM
9090
call ./PCbuild/build.bat --tail-call-interp -d -p ${{ matrix.architecture }}
9191
call ./PCbuild/rt.bat -d -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
@@ -95,26 +95,28 @@ jobs:
9595
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
9696
shell: cmd
9797
run: |
98-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.5
98+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
9999
set PlatformToolset=clangcl
100-
set LLVMToolsVersion=${{ matrix.llvm }}.1.5
100+
set LLVMToolsVersion=${{ matrix.llvm }}.1.0
101101
set LLVMInstallDir=C:\Program Files\LLVM
102102
./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }}
103103
104104
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
105105
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
106106
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
107107
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
108+
# Note: when a new LLVM is released, the homebrew installation directory changes, so the builds will fail.
109+
# We either need to upgrade LLVM or change the directory being pointed to.
108110
- name: Native macOS (release)
109111
if: runner.os == 'macOS'
110112
run: |
111113
brew update
112114
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
113115
brew install llvm@${{ matrix.llvm }}
114116
export SDKROOT="$(xcrun --show-sdk-path)"
115-
export PATH="/opt/homebrew/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
116-
export PATH="/usr/local/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
117-
CC=clang-19 ./configure --with-tail-call-interp
117+
export PATH="/usr/local/opt/llvm/bin:$PATH"
118+
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
119+
CC=clang-20 ./configure --with-tail-call-interp
118120
make all --jobs 4
119121
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
120122
@@ -123,7 +125,7 @@ jobs:
123125
run: |
124126
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
125127
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
126-
CC=clang-19 ./configure --with-tail-call-interp --with-pydebug
128+
CC=clang-20 ./configure --with-tail-call-interp --with-pydebug
127129
make all --jobs 4
128130
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
129131
@@ -132,7 +134,7 @@ jobs:
132134
run: |
133135
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
134136
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
135-
CC=clang-19 ./configure --with-tail-call-interp --disable-gil
137+
CC=clang-20 ./configure --with-tail-call-interp --disable-gil
136138
make all --jobs 4
137139
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
138140

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tags
3838
TAGS
3939
.vs/
4040
.vscode/
41+
.cache/
4142
gmon.out
4243
.coverage
4344
.mypy_cache/

Doc/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ dist-html:
204204
find dist -name 'python-$(DISTVERSION)-docs-html*' -exec rm -rf {} \;
205205
$(MAKE) html
206206
cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
207+
rm -rf dist/python-$(DISTVERSION)-docs-html/_images/social_previews/
207208
tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
208209
bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
209210
(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)

Doc/c-api/arg.rst

+32-2
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,18 @@ There are three ways strings and buffers can be converted to C:
113113
``z`` (:class:`str` or ``None``) [const char \*]
114114
Like ``s``, but the Python object may also be ``None``, in which case the C
115115
pointer is set to ``NULL``.
116+
It is the same as ``s?`` with the C pointer was initialized to ``NULL``.
116117

117118
``z*`` (:class:`str`, :term:`bytes-like object` or ``None``) [Py_buffer]
118119
Like ``s*``, but the Python object may also be ``None``, in which case the
119120
``buf`` member of the :c:type:`Py_buffer` structure is set to ``NULL``.
121+
It is the same as ``s*?`` with the ``buf`` member of the :c:type:`Py_buffer`
122+
structure was initialized to ``NULL``.
120123

121124
``z#`` (:class:`str`, read-only :term:`bytes-like object` or ``None``) [const char \*, :c:type:`Py_ssize_t`]
122125
Like ``s#``, but the Python object may also be ``None``, in which case the C
123126
pointer is set to ``NULL``.
127+
It is the same as ``s#?`` with the C pointer was initialized to ``NULL``.
124128

125129
``y`` (read-only :term:`bytes-like object`) [const char \*]
126130
This format converts a bytes-like object to a C pointer to a
@@ -357,11 +361,37 @@ Other objects
357361

358362
.. versionadded:: 3.3
359363

360-
``(items)`` (:class:`tuple`) [*matching-items*]
361-
The object must be a Python sequence whose length is the number of format units
364+
``(items)`` (sequence) [*matching-items*]
365+
The object must be a Python sequence (except :class:`str`, :class:`bytes`
366+
or :class:`bytearray`) whose length is the number of format units
362367
in *items*. The C arguments must correspond to the individual format units in
363368
*items*. Format units for sequences may be nested.
364369

370+
If *items* contains format units which store a :ref:`borrowed buffer
371+
<c-arg-borrowed-buffer>` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``)
372+
or a :term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, or ``O!``),
373+
the object must be a Python tuple.
374+
The *converter* for the ``O&`` format unit in *items* must not store
375+
a borrowed buffer or a borrowed reference.
376+
377+
.. versionchanged:: next
378+
:class:`str` and :class:`bytearray` objects no longer accepted as a sequence.
379+
380+
.. deprecated:: next
381+
Non-tuple sequences are deprecated if *items* contains format units
382+
which store a borrowed buffer or a borrowed reference.
383+
384+
``unit?`` (anything or ``None``) [*matching-variable(s)*]
385+
``?`` modifies the behavior of the preceding format unit.
386+
The C variable(s) corresponding to that parameter should be initialized
387+
to their default value --- when the argument is ``None``,
388+
:c:func:`PyArg_ParseTuple` does not touch the contents of the corresponding
389+
C variable(s).
390+
If the argument is not ``None``, it is parsed according to the specified
391+
format unit.
392+
393+
.. versionadded:: next
394+
365395
A few other characters have a meaning in a format string. These may not occur
366396
inside nested parentheses. They are:
367397

Doc/c-api/buffer.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ characteristic of being backed by a possibly large memory buffer. It is
2626
then desirable, in some situations, to access that buffer directly and
2727
without intermediate copying.
2828

29-
Python provides such a facility at the C level in the form of the :ref:`buffer
30-
protocol <bufferobjects>`. This protocol has two sides:
29+
Python provides such a facility at the C and Python level in the form of the
30+
:ref:`buffer protocol <bufferobjects>`. This protocol has two sides:
3131

3232
.. index:: single: PyBufferProcs (C type)
3333

3434
- on the producer side, a type can export a "buffer interface" which allows
3535
objects of that type to expose information about their underlying buffer.
36-
This interface is described in the section :ref:`buffer-structs`;
36+
This interface is described in the section :ref:`buffer-structs`; for
37+
Python see :ref:`python-buffer-protocol`.
3738

3839
- on the consumer side, several means are available to obtain a pointer to
39-
the raw underlying data of an object (for example a method parameter).
40+
the raw underlying data of an object (for example a method parameter). For
41+
Python see :class:`memoryview`.
4042

4143
Simple objects such as :class:`bytes` and :class:`bytearray` expose their
4244
underlying buffer in byte-oriented form. Other forms are possible; for example,
@@ -62,6 +64,10 @@ In both cases, :c:func:`PyBuffer_Release` must be called when the buffer
6264
isn't needed anymore. Failure to do so could lead to various issues such as
6365
resource leaks.
6466

67+
.. versionadded:: 3.12
68+
69+
The buffer protocol is now accessible in Python, see
70+
:ref:`python-buffer-protocol` and :class:`memoryview`.
6571

6672
.. _buffer-structure:
6773

Doc/c-api/gcsupport.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ the garbage collector.
277277
278278
Type of the visitor function to be passed to :c:func:`PyUnstable_GC_VisitObjects`.
279279
*arg* is the same as the *arg* passed to ``PyUnstable_GC_VisitObjects``.
280-
Return ``0`` to continue iteration, return ``1`` to stop iteration. Other return
280+
Return ``1`` to continue iteration, return ``0`` to stop iteration. Other return
281281
values are reserved for now so behavior on returning anything else is undefined.
282282
283283
.. versionadded:: 3.12

Doc/c-api/monitoring.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ would typically correspond to a python function.
205205
206206
.. versionadded:: 3.13
207207
208-
.. deprecated:: next
208+
.. deprecated:: 3.14
209209
210210
This function is :term:`soft deprecated`.

0 commit comments

Comments
 (0)