Skip to content

Commit 8ed1a65

Browse files
Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts: # Doc/builtins/functions.rst # Doc/library/code.rst # Lib/code.py
2 parents 76e5741 + 8293654 commit 8ed1a65

440 files changed

Lines changed: 38304 additions & 38651 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: 7 additions & 3 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
@@ -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) }}
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) \

‎Doc/builtins/stdtypes.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ expression support in the :mod:`re` module).
21572157

21582158
The casefolding algorithm is `described in section 3.13.3 'Default Case
21592159
Folding' of the Unicode Standard
2160-
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G53253>`__.
2160+
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G53253>`__.
21612161

21622162
.. versionadded:: 3.3
21632163

@@ -2398,7 +2398,7 @@ expression support in the :mod:`re` module).
23982398
property being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is different
23992399
from the `Alphabetic property defined in section 4.10 'Letters, Alphabetic, and
24002400
Ideographic' of the Unicode Standard
2401-
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-4/#G91002>`__.
2401+
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-4/#G91002>`__.
24022402
For example:
24032403

24042404
.. doctest::
@@ -2664,7 +2664,7 @@ expression support in the :mod:`re` module).
26642664

26652665
The lowercasing algorithm used is `described in section 3.13.2 'Default Case
26662666
Conversion' of the Unicode Standard
2667-
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G34078>`__.
2667+
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
26682668

26692669

26702670
.. method:: str.lstrip(chars=None, /)
@@ -3176,7 +3176,7 @@ expression support in the :mod:`re` module).
31763176

31773177
The uppercasing algorithm used is `described in section 3.13.2 'Default Case
31783178
Conversion' of the Unicode Standard
3179-
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G34078>`__.
3179+
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
31803180

31813181

31823182
.. method:: str.zfill(width, /)

‎Doc/c-api/bytes.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ called with a non-bytes parameter.
249249
250250
While bytes objects are usually immutable in Python, this special C API
251251
allows mutating a bytes object in-place. The returned bytes object can still
252-
be mutated using :c:func:`PyBytesWriter_GetData`; except if *newsize* is
252+
be mutated using :c:func:`PyBytes_AsString`; except if *newsize* is
253253
zero in which case it returns the immutable empty bytes string.
254254
255255
.. soft-deprecated:: 3.15
@@ -305,8 +305,8 @@ object.
305305
306306
A bytes writer object.
307307
308-
The API is **not thread safe**. A :c:type:`PyBytesWriter` object must only
309-
be used by a single thread, it must not be shared between threads.
308+
The API is **not thread safe**. To share a writer with multiple threads, a
309+
critical section or a lock is needed.
310310
311311
The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on
312312
success, or :c:func:`PyBytesWriter_Discard` on error.

‎Doc/c-api/interp-lifecycle.rst‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ The following functions can be safely called before Python is initialized:
7474

7575
Despite their apparent similarity to some of the functions listed above,
7676
the following functions **should not be called** before the interpreter has
77-
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`PyEval_InitThreads`, and
78-
:c:func:`Py_RunMain`.
77+
been initialized: :c:func:`Py_EncodeLocale`, and :c:func:`Py_RunMain`.
7978

8079

8180
.. _global-conf-vars:
@@ -355,7 +354,6 @@ Initializing and finalizing the interpreter
355354
.. c:function:: void Py_Initialize()
356355
357356
.. index::
358-
single: PyEval_InitThreads()
359357
single: modules (in module sys)
360358
single: path (in module sys)
361359
pair: module; builtins

0 commit comments

Comments
 (0)