Skip to content

Commit 8dfd696

Browse files
Merge branch 'main' into fix-issue-157127
2 parents 3f7606e + 64d315a commit 8dfd696

821 files changed

Lines changed: 59834 additions & 49303 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.

‎.claude/CLAUDE.md‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎.github/CODEOWNERS‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ Tools/jit/ @brandtbucher @savannahostrowski @diegorusso
290290
InternalDocs/jit.md @brandtbucher @savannahostrowski @diegorusso @AA-Turner
291291

292292
# Lazy imports (PEP 810)
293-
Objects/lazyimportobject.c @yhg1s @DinoV @pablogsal
294-
Include/internal/pycore_lazyimportobject.h @yhg1s @DinoV @pablogsal
295-
Lib/test/test_lazy_import @yhg1s @DinoV @pablogsal
293+
.github/workflows/reusable-test-lazy-imports-all.yml @yhg1s @DinoV @pablogsal
294+
Objects/lazyimportobject.c @yhg1s @DinoV @pablogsal
295+
Include/internal/pycore_lazyimportobject.h @yhg1s @DinoV @pablogsal
296+
Lib/test/test_lazy_import @yhg1s @DinoV @pablogsal
296297

297298
# Micro-op / μop / Tier 2 Optimiser
298299
Python/optimizer.c @markshannon @Fidget-Spinner
@@ -630,7 +631,7 @@ Lib/test/test_unittest/testmock/ @cjw296
630631
Doc/library/zlib.rst @StanFromIreland
631632
Lib/compression/zlib.py @StanFromIreland
632633
Lib/test/test_zlib.py @StanFromIreland
633-
Modules/_zlibmodule.c @StanFromIreland
634+
Modules/zlibmodule.c @StanFromIreland
634635

635636
# Zipfile.Path
636637
Lib/test/test_zipfile/_path/ @jaraco
@@ -655,5 +656,8 @@ Objects/**/clinic/
655656
PC/**/clinic/
656657
Python/**/clinic/
657658

659+
# Exclude Lazy Imports=all CI carve out file
660+
Lib/test/lazy_imports_all_exclude.txt
661+
658662
# Exclude HTML IDs list
659663
Doc/tools/removed-ids.txt

‎.github/workflows/build.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ jobs:
476476
name: hypothesis-example-db
477477
path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/examples/
478478

479+
test-lazy-imports-all:
480+
name: 'Lazy imports enabled'
481+
needs: build-context
482+
if: fromJSON(needs.build-context.outputs.run-tests)
483+
uses: ./.github/workflows/reusable-test-lazy-imports-all.yml
484+
479485
build-asan:
480486
name: 'Address sanitizer'
481487
runs-on: ${{ matrix.os }}
@@ -648,6 +654,7 @@ jobs:
648654
- build-emscripten
649655
- build-wasi
650656
- test-hypothesis
657+
- test-lazy-imports-all
651658
- build-asan
652659
- build-san
653660
- cross-build-linux
@@ -705,4 +712,5 @@ jobs:
705712
${{ !fromJSON(needs.build-context.outputs.run-ios) && 'build-ios,' || '' }}
706713
${{ !fromJSON(needs.build-context.outputs.run-emscripten) && 'build-emscripten,' || '' }}
707714
${{ !fromJSON(needs.build-context.outputs.run-wasi) && 'build-wasi,' || '' }}
715+
${{ !fromJSON(needs.build-context.outputs.run-tests) && 'test-lazy-imports-all,' || '' }}
708716
jobs: ${{ toJSON(needs) }}

‎.github/workflows/reusable-docs.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ jobs:
8686
--fail-if-regression \
8787
--fail-if-improved \
8888
--fail-if-new-news-nit
89+
- name: 'Build list of changes'
90+
run: |
91+
make -C Doc/ PYTHON=../python changes
8992
- name: 'Collect HTML IDs'
9093
if: github.event_name == 'pull_request'
9194
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Reusable Lazy Imports Tests
2+
3+
# Run the CPython test suite with global lazy imports forced on
4+
# (``-X lazy_imports=all``).
5+
#
6+
# Modules that are known to fail under lazy imports are listed in
7+
# Lib/test/lazy_imports_all_exclude.txt and skipped here. Remove entries from
8+
# that file as the modules are fixed so this workflow starts guarding them
9+
# against regressions. Excluded modules are also checked separately so the
10+
# workflow fails when one starts passing and its exclusion should be removed.
11+
12+
on:
13+
workflow_call:
14+
15+
permissions:
16+
contents: read
17+
18+
env:
19+
FORCE_COLOR: 1
20+
21+
jobs:
22+
test-lazy-imports-all:
23+
name: 'Run Tests with lazy_imports=all'
24+
runs-on: ubuntu-26.04
25+
timeout-minutes: 60
26+
env:
27+
EXCLUDE_FILE: Lib/test/lazy_imports_all_exclude.txt
28+
steps:
29+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
30+
with:
31+
persist-credentials: false
32+
- name: Register gcc problem matcher
33+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
34+
- name: Install dependencies
35+
run: sudo ./.github/workflows/posix-deps-apt.sh
36+
- name: Configure CPython
37+
run: ./configure --config-cache --with-pydebug
38+
- name: Build CPython
39+
run: make -j4
40+
- name: Display build info
41+
run: make pythoninfo
42+
- name: Verify lazy imports are fully enabled
43+
run: ./python -X lazy_imports=all -c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')"
44+
- name: Build test list (all tests minus the known-failing exclusions)
45+
run: |
46+
set -euo pipefail
47+
./python -m test --list-tests > all_tests.txt
48+
# Strip comments/blank lines from the exclusion file, then drop those
49+
# exact test names (whole-line, fixed-string match) from the run list.
50+
grep -vE '^\s*(#.*)?$' "$EXCLUDE_FILE" > exclude_tests.txt || true
51+
grep -vxF -f exclude_tests.txt all_tests.txt > run_tests.txt
52+
# Fail loudly if any exclusion entry matched nothing: a stale or
53+
# mistyped name (or a change in `--list-tests` output) would otherwise
54+
# silently stop excluding a module and let it fail the run.
55+
stale=$(comm -23 <(sort -u exclude_tests.txt) <(sort -u all_tests.txt))
56+
if [ -n "$stale" ]; then
57+
echo "::error::Stale entries in $EXCLUDE_FILE (no longer match 'python -m test --list-tests'); remove or fix them:"
58+
echo "$stale"
59+
exit 1
60+
fi
61+
echo "Excluding $(wc -l < exclude_tests.txt) module(s); running $(wc -l < run_tests.txt) of $(wc -l < all_tests.txt)."
62+
- name: Run tests with lazy imports
63+
run: xvfb-run xargs -a run_tests.txt ./python -X lazy_imports=all -m test --fast-ci --timeout=900 < /dev/null
64+
- name: Verify excluded tests still need exclusion
65+
run: |
66+
set -euo pipefail
67+
unexpected_passes=()
68+
while IFS= read -r test_name; do
69+
[ -n "$test_name" ] || continue
70+
echo "Checking excluded test: $test_name"
71+
if xvfb-run ./python -X lazy_imports=all -m test --fast-ci --timeout=900 "$test_name"; then
72+
unexpected_passes+=("$test_name")
73+
fi
74+
done < exclude_tests.txt
75+
if [ "${#unexpected_passes[@]}" -ne 0 ]; then
76+
echo "::error::These tests still appear in $EXCLUDE_FILE but now pass with -X lazy_imports=all. Remove them from the exclude file:"
77+
printf '%s\n' "${unexpected_passes[@]}"
78+
exit 1
79+
fi

‎.github/workflows/reusable-wasi.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-26.04-arm
1616
timeout-minutes: 60
1717
env:
18-
WASMTIME_VERSION: 38.0.3
18+
WASMTIME_VERSION: 48.0.2
1919
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2020
steps:
2121
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

‎.pre-commit-config.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ repos:
143143
entry: Space found in path, move to Misc/NEWS.d/next/Core_and_Builtins/
144144
files: Misc/NEWS.d/next/Core and Builtins/20.*.rst
145145

146+
- repo: local
147+
hooks:
148+
- id: check-capi-macros
149+
name: Check C API macros start with Py
150+
language: python
151+
entry: python Tools/build/check_capi_macros.py
152+
pass_filenames: false
153+
files: ^(Include/(cpython/)?[^/]+\.h|pyconfig\.h\.in|Tools/build/check_capi_macros)
154+
146155
- repo: meta
147156
hooks:
148157
- id: check-hooks-apply

‎Doc/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ lock:
191191
# Dependencies have a 14 day cooldown period to mitigate supply chain attacks,
192192
# except for sphinx_linklint and python-docs-theme, which are maintained by
193193
# core team members.
194-
uv pip compile requirements.txt \
195-
--exclude-newer P14D \
194+
$(UV) pip compile requirements.txt \
195+
--upgrade --exclude-newer P14D \
196196
--exclude-newer-package sphinx_linklint=PT0S \
197197
--exclude-newer-package python-docs-theme=PT0S \
198198
--no-cache --output-file $(REQUIREMENTS) \
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)