Skip to content

Commit ef98362

Browse files
authored
Merge branch 'main' into fix/issue-157466-configparser-empty-value-trailing-space
2 parents a6e531c + b0dda15 commit ef98362

220 files changed

Lines changed: 8201 additions & 5836 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/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/c-api/bytes.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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/unicode.rst‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ points must be below 1114112 (which is the full Unicode range).
1616

1717
UTF-8 representation is created on demand and cached in the Unicode object.
1818

19+
.. impl-detail::
20+
21+
The internal buffer always includes an extra trailing null character for
22+
compatibility with null terminated C strings. This extra character is not
23+
counted in :c:func:`PyUnicode_GetLength` nor in the various *size* arguments
24+
of the functions below.
25+
1926
.. note::
2027
The :c:type:`Py_UNICODE` representation has been removed since Python 3.12
2128
with deprecated APIs.
@@ -164,11 +171,15 @@ access to internal read-only data of Unicode objects:
164171
.. versionadded:: 3.3
165172
166173
167-
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, \
168-
Py_ssize_t index)
174+
.. c:function:: Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index)
169175
170176
Read a code point from a canonical representation *data* (as obtained with
171-
:c:func:`PyUnicode_DATA`). No checks or ready calls are performed.
177+
:c:func:`PyUnicode_DATA`). No checks are performed.
178+
179+
.. impl-detail::
180+
181+
Accept reading the trailing null character at index
182+
:c:func:`PyUnicode_GetLength`.
172183
173184
.. versionadded:: 3.3
174185
@@ -179,6 +190,11 @@ access to internal read-only data of Unicode objects:
179190
representation. This is less efficient than :c:func:`PyUnicode_READ` if you
180191
do multiple consecutive reads.
181192
193+
.. impl-detail::
194+
195+
Accept reading the trailing null character at index
196+
:c:func:`PyUnicode_GetLength`.
197+
182198
.. versionadded:: 3.3
183199
184200
@@ -716,6 +732,10 @@ APIs:
716732
717733
On error, set an exception and return ``-1``.
718734
735+
.. impl-detail::
736+
737+
The length does not count the trailing null character.
738+
719739
.. versionadded:: 3.3
720740
721741
@@ -794,6 +814,11 @@ APIs:
794814
795815
Return character on success, ``-1`` on error with an exception set.
796816
817+
.. impl-detail::
818+
819+
Do not accept reading the trailing null character at index
820+
:c:func:`PyUnicode_GetLength`.
821+
797822
.. versionadded:: 3.3
798823
799824
@@ -1797,6 +1822,9 @@ object.
17971822
The instance must be destroyed by :c:func:`PyUnicodeWriter_Finish` on
17981823
success, or :c:func:`PyUnicodeWriter_Discard` on error.
17991824
1825+
The API is **not thread safe**. To share a writer with multiple threads, a
1826+
critical section or a lock is needed.
1827+
18001828
.. c:function:: PyUnicodeWriter* PyUnicodeWriter_Create(Py_ssize_t length)
18011829
18021830
Create a Unicode writer instance.

‎Doc/conf.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,40 @@
636636
"library/threadsafety.rst": "builtins/threadsafety.rst",
637637
"library/time-complexity.rst": "builtins/time-complexity.rst",
638638
}
639+
640+
# Refuse to run the doctest builder under a mismatched Python
641+
# -----------------------------------------------------------
642+
643+
644+
def _check_doctest_interpreter(app):
645+
# The doctests are executed by the interpreter running Sphinx,
646+
# so refuse to run them if its version doesn't match the source tree.
647+
if app.builder.name != "doctest":
648+
return
649+
650+
running_version = f"{sys.version_info.major}.{sys.version_info.minor}"
651+
if running_version != version:
652+
from sphinx.util import logging as sphinx_logging
653+
654+
logger = sphinx_logging.getLogger(__name__)
655+
logger.error(
656+
"The doctests are executed by the Python running Sphinx, "
657+
"which is Python %s, however this source tree is Python %s, "
658+
"so they would test Python %s rather than the code "
659+
"documented here.\n"
660+
"Recreate the venv with a matching interpreter, for example: "
661+
"'make clean-venv && make venv PYTHON=../python'.",
662+
running_version,
663+
version,
664+
running_version,
665+
)
666+
raise SystemExit(1)
667+
668+
669+
def setup(app):
670+
app.connect("builder-inited", _check_doctest_interpreter)
671+
return {
672+
"version": "1.0",
673+
"parallel_read_safe": True,
674+
"parallel_write_safe": True,
675+
}

‎Doc/library/asyncio-task.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ other coroutines::
175175
* a *coroutine object*: an object returned by calling a
176176
*coroutine function*.
177177

178+
Generator-based coroutines, created with :func:`types.coroutine`, are
179+
covered by neither term and are not supported by asyncio.
180+
178181

179182
.. rubric:: Tasks
180183

@@ -1220,6 +1223,10 @@ Introspection
12201223

12211224
.. versionadded:: 3.4
12221225

1226+
.. versionchanged:: 3.12
1227+
Generator-based coroutines are no longer supported, and ``False``
1228+
is returned for them.
1229+
12231230
.. _asyncio-task-obj:
12241231

12251232
Task object

0 commit comments

Comments
 (0)