Skip to content

Commit f60f435

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pep649-inspect
2 parents 2a1c9a9 + c4c7097 commit f60f435

File tree

866 files changed

+29465
-16430
lines changed

Some content is hidden

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

866 files changed

+29465
-16430
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM docker.io/library/fedora:40
22

33
ENV CC=clang
44

5-
ENV WASI_SDK_VERSION=21
5+
ENV WASI_SDK_VERSION=22
66
ENV WASI_SDK_PATH=/opt/wasi-sdk
77

88
ENV WASMTIME_HOME=/opt/wasmtime
9-
ENV WASMTIME_VERSION=18.0.3
9+
ENV WASMTIME_VERSION=22.0.0
1010
ENV WASMTIME_CPU_ARCH=x86_64
1111

1212
RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Python/bytecodes.c @markshannon
4242
Python/optimizer*.c @markshannon
4343
Python/optimizer_analysis.c @Fidget-Spinner
4444
Python/optimizer_bytecodes.c @Fidget-Spinner
45-
Python/symtable.c @JelleZijlstra @carljm
45+
Python/symtable.c @JelleZijlstra @carljm
4646
Lib/_pyrepl/* @pablogsal @lysnikolaou @ambv
4747
Lib/test/test_patma.py @brandtbucher
4848
Lib/test/test_type_*.py @JelleZijlstra
@@ -72,6 +72,7 @@ Include/internal/pycore_freelist.h @ericsnowcurrently
7272
Include/internal/pycore_global_objects.h @ericsnowcurrently
7373
Include/internal/pycore_obmalloc.h @ericsnowcurrently
7474
Include/internal/pycore_pymem.h @ericsnowcurrently
75+
Include/internal/pycore_stackref.h @Fidget-Spinner
7576
Modules/main.c @ericsnowcurrently
7677
Programs/_bootstrap_python.c @ericsnowcurrently
7778
Programs/python.c @ericsnowcurrently
@@ -201,7 +202,6 @@ Doc/c-api/stable.rst @encukou
201202
**/*itertools* @rhettinger
202203
**/*collections* @rhettinger
203204
**/*random* @rhettinger
204-
**/*queue* @rhettinger
205205
**/*bisect* @rhettinger
206206
**/*heapq* @rhettinger
207207
**/*functools* @rhettinger

.github/workflows/build.yml

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,31 @@ jobs:
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 10
2929
outputs:
30+
# Some of the referenced steps set outputs conditionally and there may be
31+
# cases when referencing them evaluates to empty strings. It is nice to
32+
# work with proper booleans so they have to be evaluated through JSON
33+
# conversion in the expressions. However, empty strings used like that
34+
# may trigger all sorts of undefined and hard-to-debug behaviors in
35+
# GitHub Actions CI/CD. To help with this, all of the outputs set here
36+
# that are meant to be used as boolean flags (and not arbitrary strings),
37+
# MUST have fallbacks with default values set. A common pattern would be
38+
# to add ` || false` to all such expressions here, in the output
39+
# definitions. They can then later be safely used through the following
40+
# idiom in job conditionals and other expressions. Here's some examples:
41+
#
42+
# if: fromJSON(needs.check_source.outputs.run-docs)
43+
#
44+
# ${{
45+
# fromJSON(needs.check_source.outputs.run_tests)
46+
# && 'truthy-branch'
47+
# || 'falsy-branch'
48+
# }}
49+
#
3050
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
31-
run_tests: ${{ steps.check.outputs.run_tests }}
32-
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
33-
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
34-
config_hash: ${{ steps.config_hash.outputs.hash }}
51+
run_tests: ${{ steps.check.outputs.run_tests || false }}
52+
run_hypothesis: ${{ steps.check.outputs.run_hypothesis || false }}
53+
run_cifuzz: ${{ steps.check.outputs.run_cifuzz || false }}
54+
config_hash: ${{ steps.config_hash.outputs.hash }} # str
3555
steps:
3656
- uses: actions/checkout@v4
3757
- name: Check for source changes
@@ -179,18 +199,24 @@ jobs:
179199
run: make check-c-globals
180200

181201
build_windows:
182-
name: 'Windows'
202+
name: >-
203+
Windows
204+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
183205
needs: check_source
184-
if: needs.check_source.outputs.run_tests == 'true'
185-
uses: ./.github/workflows/reusable-windows.yml
186-
187-
build_windows_free_threading:
188-
name: 'Windows (free-threading)'
189-
needs: check_source
190-
if: needs.check_source.outputs.run_tests == 'true'
206+
if: fromJSON(needs.check_source.outputs.run_tests)
207+
strategy:
208+
matrix:
209+
arch:
210+
- Win32
211+
- x64
212+
- arm64
213+
free-threading:
214+
- false
215+
- true
191216
uses: ./.github/workflows/reusable-windows.yml
192217
with:
193-
free-threading: true
218+
arch: ${{ matrix.arch }}
219+
free-threading: ${{ matrix.free-threading }}
194220

195221
build_macos:
196222
name: 'macOS'
@@ -393,7 +419,7 @@ jobs:
393419
path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/
394420
key: hypothesis-database-${{ github.head_ref || github.run_id }}
395421
restore-keys: |
396-
- hypothesis-database-
422+
hypothesis-database-
397423
- name: "Run tests"
398424
working-directory: ${{ env.CPYTHON_BUILDDIR }}
399425
run: |
@@ -556,7 +582,6 @@ jobs:
556582
- build_ubuntu_ssltests
557583
- build_wasi
558584
- build_windows
559-
- build_windows_free_threading
560585
- test_hypothesis
561586
- build_asan
562587
- build_tsan
@@ -592,7 +617,6 @@ jobs:
592617
build_ubuntu_ssltests,
593618
build_wasi,
594619
build_windows,
595-
build_windows_free_threading,
596620
build_asan,
597621
build_tsan,
598622
build_tsan_free_threading,

.github/workflows/jit.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ jobs:
133133
make all --jobs 4
134134
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
135135
136-
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
137136
- name: Native Linux
138137
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
139138
run: |
140139
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
141140
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
142-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations' }}
141+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
143142
make all --jobs 4
144143
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
145144
146-
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
147145
- name: Emulated Linux
148146
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
149147
# The --ignorefile on ./python -m test is used to exclude tests known to fail when running on an emulated Linux.
@@ -161,7 +159,7 @@ jobs:
161159
CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}" \
162160
CPP="$CC --preprocess" \
163161
HOSTRUNNER=qemu-${{ matrix.architecture }} \
164-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations ' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
162+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
165163
make all --jobs 4
166164
./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3
167165

.github/workflows/reusable-tsan.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
# Install clang-18
3737
wget https://apt.llvm.org/llvm.sh
3838
chmod +x llvm.sh
39-
sudo ./llvm.sh 18
40-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100
41-
sudo update-alternatives --set clang /usr/bin/clang-18
42-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
43-
sudo update-alternatives --set clang++ /usr/bin/clang++-18
39+
sudo ./llvm.sh 17 # gh-121946: llvm-18 package is temporarily broken
40+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100
41+
sudo update-alternatives --set clang /usr/bin/clang-17
42+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100
43+
sudo update-alternatives --set clang++ /usr/bin/clang++-17
4444
# Reduce ASLR to avoid TSAN crashing
4545
sudo sysctl -w vm.mmap_rnd_bits=28
4646
- name: TSAN Option Setup

.github/workflows/reusable-wasi.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-22.04
1313
env:
14-
WASMTIME_VERSION: 18.0.3
15-
WASI_SDK_VERSION: 21
14+
WASMTIME_VERSION: 22.0.0
15+
WASI_SDK_VERSION: 22
1616
WASI_SDK_PATH: /opt/wasi-sdk
1717
CROSS_BUILD_PYTHON: cross-build/build
1818
CROSS_BUILD_WASI: cross-build/wasm32-wasi
1919
steps:
2020
- uses: actions/checkout@v4
2121
# No problem resolver registered as one doesn't currently exist for Clang.
2222
- name: "Install wasmtime"
23-
uses: jcbhmr/setup-wasmtime@v2
23+
uses: bytecodealliance/actions/wasmtime/setup@v1
2424
with:
25-
wasmtime-version: ${{ env.WASMTIME_VERSION }}
25+
version: ${{ env.WASMTIME_VERSION }}
2626
- name: "Restore WASI SDK"
2727
id: cache-wasi-sdk
2828
uses: actions/cache@v4
@@ -50,8 +50,10 @@ jobs:
5050
uses: actions/cache@v4
5151
with:
5252
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
53-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
54-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
53+
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
54+
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
55+
# (Make sure to keep the key in sync with the other config.cache step below.)
56+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
5557
- name: "Configure build Python"
5658
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
5759
- name: "Make build Python"
@@ -60,8 +62,8 @@ jobs:
6062
uses: actions/cache@v4
6163
with:
6264
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
63-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
64-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
65+
# Should be kept in sync with the other config.cache step above.
66+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
6567
- name: "Configure host"
6668
# `--with-pydebug` inferred from configure-build-python
6769
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,45 @@
11
on:
22
workflow_call:
33
inputs:
4+
arch:
5+
description: CPU architecture
6+
required: true
7+
type: string
48
free-threading:
9+
description: Whether to compile CPython in free-threading mode
510
required: false
611
type: boolean
712
default: false
813

9-
jobs:
10-
build_win32:
11-
name: 'build and test (x86)'
12-
runs-on: windows-latest
13-
timeout-minutes: 60
14-
env:
15-
IncludeUwp: 'true'
16-
steps:
17-
- uses: actions/checkout@v4
18-
- name: Build CPython
19-
run: .\PCbuild\build.bat -e -d -v -p Win32 ${{ inputs.free-threading && '--disable-gil' || '' }}
20-
- name: Display build info
21-
run: .\python.bat -m test.pythoninfo
22-
- name: Tests
23-
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
14+
env:
15+
IncludeUwp: >-
16+
true
2417
25-
build_win_amd64:
26-
name: 'build and test (x64)'
18+
jobs:
19+
build:
20+
name: >-
21+
build${{ inputs.arch != 'arm64' && ' and test' || '' }}
22+
(${{ inputs.arch }})
2723
runs-on: windows-latest
2824
timeout-minutes: 60
29-
env:
30-
IncludeUwp: 'true'
3125
steps:
3226
- uses: actions/checkout@v4
3327
- name: Register MSVC problem matcher
28+
if: inputs.arch != 'Win32'
3429
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3530
- name: Build CPython
36-
run: .\PCbuild\build.bat -e -d -v -p x64 ${{ inputs.free-threading && '--disable-gil' || '' }}
31+
run: >-
32+
.\PCbuild\build.bat
33+
-e -d -v
34+
-p ${{ inputs.arch }}
35+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
3736
- name: Display build info
37+
if: inputs.arch != 'arm64'
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
40-
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
41-
42-
build_win_arm64:
43-
name: 'build (arm64)'
44-
runs-on: windows-latest
45-
timeout-minutes: 60
46-
env:
47-
IncludeUwp: 'true'
48-
steps:
49-
- uses: actions/checkout@v4
50-
- name: Register MSVC problem matcher
51-
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
52-
- name: Build CPython
53-
run: .\PCbuild\build.bat -e -d -v -p arm64 ${{ inputs.free-threading && '--disable-gil' || '' }}
40+
if: inputs.arch != 'arm64'
41+
run: >-
42+
.\PCbuild\rt.bat
43+
-p ${{ inputs.arch }}
44+
-d -q --fast-ci
45+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}

.pre-commit-config.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ repos:
33
rev: v0.3.4
44
hooks:
55
- id: ruff
6-
name: Run Ruff on Lib/test/
6+
name: Run Ruff (lint) on Doc/
7+
args: [--exit-non-zero-on-fix]
8+
files: ^Doc/
9+
- id: ruff
10+
name: Run Ruff (lint) on Lib/test/
711
args: [--exit-non-zero-on-fix]
812
files: ^Lib/test/
913
- id: ruff
10-
name: Run Ruff on Argument Clinic
14+
name: Run Ruff (lint) on Argument Clinic
1115
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
1216
files: ^Tools/clinic/|Lib/test/test_clinic.py
17+
- id: ruff-format
18+
name: Run Ruff (format) on Doc/
19+
args: [--check]
20+
files: ^Doc/
1321

1422
- repo: https://github.com/psf/black-pre-commit-mirror
1523
rev: 24.4.2

.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ build:
2626
exit 183;
2727
fi
2828
29+
- asdf plugin add uv
30+
- asdf install uv latest
31+
- asdf global uv latest
2932
- make -C Doc venv html
3033
- mkdir _readthedocs
3134
- mv Doc/build/html _readthedocs/html

Doc/.ruff.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
target-version = "py312" # Align with the version in oldest_supported_sphinx
2+
fix = true
3+
output-format = "full"
4+
line-length = 79
5+
extend-exclude = [
6+
"includes/*",
7+
# Temporary exclusions:
8+
"tools/extensions/escape4chm.py",
9+
"tools/extensions/pyspecific.py",
10+
]
11+
12+
[lint]
13+
preview = true
14+
select = [
15+
"C4", # flake8-comprehensions
16+
"B", # flake8-bugbear
17+
"E", # pycodestyle
18+
"F", # pyflakes
19+
"FA", # flake8-future-annotations
20+
"FLY", # flynt
21+
"FURB", # refurb
22+
"G", # flake8-logging-format
23+
"I", # isort
24+
"LOG", # flake8-logging
25+
"N", # pep8-naming
26+
"PERF", # perflint
27+
"PGH", # pygrep-hooks
28+
"PT", # flake8-pytest-style
29+
"TCH", # flake8-type-checking
30+
"UP", # pyupgrade
31+
"W", # pycodestyle
32+
]
33+
ignore = [
34+
"E501", # Ignore line length errors (we use auto-formatting)
35+
]
36+
37+
[format]
38+
preview = true
39+
quote-style = "preserve"
40+
docstring-code-format = true
41+
exclude = [
42+
"tools/extensions/lexers/*",
43+
]

0 commit comments

Comments
 (0)