8000 Merge branch '3.13' into backport-d2b9b6f-3.13 · python/cpython@04d18c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04d18c8

Browse files
authored
Merge branch '3.13' into backport-d2b9b6f-3.13
2 parents c8c640b + 8b9bd43 commit 04d18c8

File tree

301 files changed

+4156
-2220
lines changed

Some content is hidden

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

301 files changed

+4156
-2220
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ Lib/test/cjkencodings/* noeol
2727
Lib/test/tokenizedata/coding20731.py noeol
2828
Lib/test/decimaltestdata/*.decTest noeol
2929
Lib/test/test_email/data/*.txt noeol
30-
Lib/test/test_importlib/resources/data01/* noeol
31-
Lib/test/test_importlib/resources/namespacedata01/* noeol
3230
Lib/test/xmltestdata/* noeol
3331

3432
# Shell scripts should have LF even on Windows because of Cygwin

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,14 @@ jobs:
238238

239239
build_ubuntu_ssltests:
240240
name: 'Ubuntu SSL tests with OpenSSL'
241-
runs-on: ubuntu-22.04
241+
runs-on: ${{ matrix.os }}
242242
timeout-minutes: 60
243243
needs: check_source
244244
if: needs.check_source.outputs.run_tests == 'true'
245245
strategy:
246246
fail-fast: false
247247
matrix:
248+
os: [ubuntu-22.04]
248249
openssl_ver: [3.0.15, 3.1.7, 3.2.3, 3.3.2]
249250
env:
250251
OPENSSL_VER: ${{ matrix.openssl_ver }}
@@ -274,7 +275,7 @@ jobs:
274275
uses: actions/cache@v4
275276
with:
276277
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
277-
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
278+
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
278279
- name: Install OpenSSL
279280
if: steps.cache-openssl.outputs.cache-hit != 'true'
280281
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
@@ -452,7 +453,7 @@ jobs:
452453
uses: actions/cache@v4
453454
with:
454455
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
455-
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
456+
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
456457
- name: Install OpenSSL
457458
if: steps.cache-openssl.outputs.cache-hit != 'true'
458459
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux

.github/workflows/reusable-ubuntu.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ jobs:
1414
build_ubuntu_reusable:
1515
name: 'build and test'
1616
timeout-minutes: 60
17-
runs-on: ubuntu-22.04
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-22.04]
1822
env:
1923
FORCE_COLOR: 1
2024
OPENSSL_VER: 3.0.15
@@ -36,7 +40,7 @@ jobs:
3640
uses: actions/cache@v4
3741
with:
3842
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
39-
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
43+
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
4044
- name: Install OpenSSL
4145
if: steps.cache-openssl.outputs.cache-hit != 'true'
4246
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.3.4
3+
rev: v0.6.7
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/

Android/README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Python for Android
22

33
These instructions are only needed if you're planning to compile Python for
4-
Android yourself. Most users should *not* need to do this. If you're looking to
5-
use Python on Android, one of the following tools will provide a much more
6-
approachable user experience:
7-
8-
* [Briefcase](https://briefcase.readthedocs.io), from the BeeWare project
9-
* [Buildozer](https://buildozer.readthedocs.io), from the Kivy project
10-
* [Chaquopy](https://chaquo.com/chaquopy/)
4+
Android yourself. Most users should *not* need to do this. Instead, use one of
5+
the tools listed in `Doc/using/android.rst`, which will provide a much easier
6+
experience.
117

128

139
## Prerequisites
1410

15-
Export the `ANDROID_HOME` environment variable to point at your Android SDK. If
16-
you don't already have the SDK, here's how to install it:
11+
First, make sure you have all the usual tools and libraries needed to build
12+
Python for your development machine.
13+
14+
Second, you'll need an Android SDK. If you already have the SDK installed,
15+
export the `ANDROID_HOME` environment variable to point at its location.
16+
Otherwise, here's how to install it:
1717

1818
* Download the "Command line tools" from <https://developer.android.com/studio>.
1919
* Create a directory `android-sdk/cmdline-tools`, and unzip the command line
@@ -37,11 +37,6 @@ development tools, which currently means Linux or macOS. This involves doing a
3737
cross-build where you use a "build" Python (for your development machine) to
3838
help produce a "host" Python for Android.
3939

40-
First, make sure you have all the usual tools and libraries needed to build
41-
Python for your development machine. The only Android tool you need to install
42-
is the command line tools package above: the build script will download the
43-
rest.
44-
4540
The easiest way to do a build is to use the `android.py` script. You can either
4641
have it perform the entire build process from start to finish in one step, or
4742
you can do it in discrete steps that mirror running `configure` and `make` for
@@ -80,17 +75,20 @@ call. For example, if you want a pydebug build that also caches the results from
8075

8176
## Testing
8277

83-
The tests can be run on Linux, macOS, or Windows, although on Windows you'll
84-
have to build the `cross-build/HOST` subdirectory on one of the other platforms
85-
and copy it over.
78+
The test suite can be run on Linux, macOS, or Windows:
8679

87-
The test suite can usually be run on a device with 2 GB of RAM, though for some
88-
configurations or test orders you may need to increase this. As of Android
80+
* On Linux, the emulator needs access to the KVM virtualization interface, and
81+
a DISPLAY environment variable pointing at an X server.
82+
* On Windows, you won't be able to do the build on the same machine, so you'll
83+
have to copy the `cross-build/HOST` directory from somewhere else.
84+
85+
The test suite can usually be run on a device with 2 GB of RAM, but this is
86+
borderline, so you may need to increase it to 4 GB. As of Android
8987
Studio Koala, 2 GB is the default for all emulators, although the user interface
90-
may indicate otherwise. The effective setting is `hw.ramSize` in
91-
~/.android/avd/*.avd/hardware-qemu.ini, whereas Android Studio displays the
92-
value from config.ini. Changing the value in Android Studio will update both of
93-
these files.
88+
may indicate otherwise. Locate the emulator's directory under `~/.android/avd`,
89+
and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these
90+
manually to the same value, or use the Android Studio Device Manager, which will
91+
update both files.
9492

9593
Before running the test suite, follow the instructions in the previous section
9694
to build the architecture you want to test. Then run the test script in one of
@@ -131,3 +129,8 @@ Every time you run `android.py test`, changes in pure-Python files in the
131129
repository's `Lib` directory will be picked up immediately. Changes in C files,
132130
and architecture-specific files such as sysconfigdata, will not take effect
133131
until you re-run `android.py make-host` or `build`.
132+
133+
134+
## Using in your own app
135+
136+
See `Doc/using/android.rst`.

Android/android.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def setup_testbed():
259259
f"{temp_dir}/{outer_jar}", "gradle-wrapper.jar"])
260260

261261

262-
# run_testbed will build the app automatically, but it hides the Gradle output
263-
# by default, so it's useful to have this as a separate command for the buildbot.
262+
# run_testbed will build the app automatically, but it's useful to have this as
263+
# a separate command to allow running the app outside of this script.
264264
def build_testbed(context):
265265
setup_sdk()
266266
setup_testbed()
@@ -376,6 +376,8 @@ async def find_pid(serial):
376376
shown_error = False
377377
while True:
378378
try:
379+
# `pidof` requires API level 24 or higher. The level 23 emulator
380+
# includes it, but it doesn't work (it returns all processes).
379381
pid = (await async_check_output(
380382
adb, "-s", serial, "shell", "pidof", "-s", APP_ID
381383
)).strip()
@@ -407,6 +409,7 @@ async def logcat_task(context, initial_devices):
407409
serial = await wait_for(find_device(context, initial_devices), startup_timeout)
408410
pid = await wait_for(find_pid(serial), startup_timeout)
409411

412+
# `--pid` requires API level 24 or higher.
410413
args = [adb, "-s", serial, "logcat", "--pid", pid, "--format", "tag"]
411414
hidden_output = []
412415
async with async_process(
@@ -421,11 +424,15 @@ async def logcat_task(context, initial_devices):
421424
# such messages, but other components might.
422425
level, message = None, line
423426

427+
# Exclude high-volume messages which are rarely useful.
428+
if context.verbose < 2 and "from python test_syslog" in message:
429+
continue
430+
424431
# Put high-level messages on stderr so they're highlighted in the
425432
# buildbot logs. This will include Python's own stderr.
426433
stream = (
427434
sys.stderr
428-
if level in ["E", "F"] # ERROR and FATAL (aka ASSERT)
435+
if level in ["W", "E", "F"] # WARNING, ERROR, FATAL (aka ASSERT)
429436
else sys.stdout
430437
)
431438

@@ -573,8 +580,9 @@ def parse_args():
573580
test = subcommands.add_parser(
574581
"test", help="Run the test suite")
575582
test.add_argument(
576-
"-v", "--verbose", action="store_true",
577-
help="Show Gradle output, and non-Python logcat messages")
583+
"-v", "--verbose", action="count", default=0,
584+
help="Show Gradle output, and non-Python logcat messages. "
585+
"Use twice to include high-volume messages which are rarely useful.")
578586
device_group = test.add_mutually_exclusive_group(required=True)
579587
device_group.add_argument(
580588
"--connected", metavar="SERIAL", help="Run on a connected device. "
@@ -591,6 +599,13 @@ def parse_args():
591599

592600
def main():
593601
install_signal_handler()
602+
603+
# Under the buildbot, stdout is not a TTY, but we must still flush after
604+
# every line to make sure our output appears in the correct order relative
605+
# to the output of our subprocesses.
606+
for stream in [sys.stdout, sys.stderr]:
607+
stream.reconfigure(line_buffering=True)
608+
594609
context = parse_args()
595610
dispatch = {"configure-build": configure_build_python,
596611
"make-build": make_build_python,

Android/testbed/app/src/main/python/main.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@
55
import sys
66

77
# Some tests use SIGUSR1, but that's blocked by default in an Android app in
8-
# order to make it available to `sigwait` in the "Signal Catcher" thread. That
9-
# thread's functionality is only relevant to the JVM ("forcing GC (no HPROF) and
10-
# profile save"), so disabling it should not weaken the tests.
8+
# order to make it available to `sigwait` in the Signal Catcher thread.
9+
# (https://cs.android.com/android/platform/superproject/+/android14-qpr3-release:art/runtime/signal_catcher.cc).
10+
# That thread's functionality is only useful for debugging the JVM, so disabling
11+
# it should not weaken the tests.
12+
#
13+
# There's no safe way of stopping the thread completely (#123982), but simply
14+
# unblocking SIGUSR1 is enough to fix most tests.
15+
#
16+
# However, in tests that generate multiple different signals in quick
17+
# succession, it's possible for SIGUSR1 to arrive while the main thread is busy
18+
# running the C-level handler for a different signal. In that case, the SIGUSR1
19+
# may be sent to the Signal Catcher thread instead, which will generate a log
20+
# message containing the text "reacting to signal".
21+
#
22+
# Such tests may need to be changed in one of the following ways:
23+
# * Use a signal other than SIGUSR1 (e.g. test_stress_delivery_simultaneous in
24+
# test_signal.py).
25+
# * Send the signal to a specific thread rather than the whole process (e.g.
26+
# test_signals in test_threadsignals.py.
1127
signal.pthread_sigmask(signal.SIG_UNBLOCK, [signal.SIGUSR1])
1228

1329
sys.argv[1:] = shlex.split(os.environ["PYTHON_ARGS"])

Doc/Makefile

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ pydoc-topics: build
144144

145145
.PHONY: gettext
146146
gettext: BUILDER = gettext
147-
gettext: SPHINXOPTS += '-d build/doctrees-gettext'
147+
gettext: SPHINXOPTS += -d build/doctrees-gettext
148148
gettext: build
149149

150150
.PHONY: htmlview
151151
htmlview: html
152152
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
153153

154154
.PHONY: htmllive
155-
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
155+
htmllive: SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-autobuild
156156
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
157157
htmllive: _ensure-sphinx-autobuild html
158158

@@ -182,13 +182,26 @@ venv:
182182
echo "The venv has been created in the $(VENVDIR) directory"; \
183183
fi
184184

185+
.PHONY: dist-no-html
186+
dist-no-html: dist-text dist-pdf dist-epub dist-texinfo
187+
185188
.PHONY: dist
186189
dist:
187190
rm -rf dist
188191
mkdir -p dist
189-
192+
$(MAKE) dist-html
193+
$(MAKE) dist-text
194+
$(MAKE) dist-pdf
195+
$(MAKE) dist-epub
196+
$(MAKE) dist-texinfo
197+
198+
.PHONY: dist-html
199+
dist-html:
190200
# archive the HTML
191201
@echo "Building HTML..."
202+
mkdir -p dist
203+
rm -rf build/html
204+
find dist -name 'python-$(DISTVERSION)-docs-html*' -exec rm -rf {} \;
192205
$(MAKE) html
193206
cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
194207
tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
@@ -198,8 +211,13 @@ dist:
198211
rm dist/python-$(DISTVERSION)-docs-html.tar
199212
@echo "Build finished and archived!"
200213

214+
.PHONY: dist-text
215+
dist-text:
201216
# archive the text build
202217
@echo "Building text..."
218+
mkdir -p dist
219+
rm -rf build/text
220+
find dist -name 'python-$(DISTVERSION)-docs-text*' -exec rm -rf {} \;
203221
$(MAKE) text
204222
cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
205223
tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
@@ -209,9 +227,13 @@ dist:
209227
rm dist/python-$(DISTVERSION)-docs-text.tar
210228
@echo "Build finished and archived!"
211229

230+
.PHONY: dist-pdf
231+
dist-pdf:
212232
# archive the A4 latex
213233
@echo "Building LaTeX (A4 paper)..."
234+
mkdir -p dist
214235
rm -rf build/latex
236+
find dist -name 'python-$(DISTVERSION)-docs-pdf*' -exec rm -rf {} \;
215237
$(MAKE) latex PAPER=a4
216238
# remove zip & bz2 dependency on all-pdf,
217239
# as otherwise the full latexmk process is run twice.
@@ -222,26 +244,24 @@ dist:
222244
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
223245
@echo "Build finished and archived!"
224246

225-
# archive the letter latex
226-
@echo "Building LaTeX (US paper)..."
227-
rm -rf build/latex
228-
$(MAKE) latex PAPER=letter
229-
-sed -i 's/: all-$$(FMT)/:/' build/latex/Makefile
230-
(cd build/latex; $(MAKE) clean && $(MAKE) --jobs=$$((`nproc`+1)) --output-sync LATEXMKOPTS='-quiet' all-pdf && $(MAKE) FMT=pdf zip bz2)
231-
cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
232-
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
233-
@echo "Build finished and archived!"
234-
247+
.PHONY: dist-epub
248+
dist-epub:
235249
# copy the epub build
236250
@echo "Building EPUB..."
251+
mkdir -p dist
237252
rm -rf build/epub
253+
rm -f dist/python-$(DISTVERSION)-docs.epub
238254
$(MAKE) epub
239255
cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
240256
@echo "Build finished and archived!"
241257

258+
.PHONY: dist-texinfo
259+
dist-texinfo:
242260
# archive the texinfo build
243261
@echo "Building Texinfo..."
262+
mkdir -p dist
244263
rm -rf build/texinfo
264+
find dist -name 'python-$(DISTVERSION)-docs-texinfo*' -exec rm -rf {} \;
245265
$(MAKE) texinfo
246266
$(MAKE) info --directory=build/texinfo
247267
cp -pPR build/texinfo dist/python-$(DISTVERSION)-docs-texinfo

Doc/c-api/buffer.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ The following fields are not influenced by *flags* and must always be filled in
244244
with the correct values: :c:member:`~Py_buffer.obj`, :c:member:`~Py_buffer.buf`,
245245
:c:member:`~Py_buffer.len`, :c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`.
246246

247-
248247
readonly, format
249248
~~~~~~~~~~~~~~~~
250249

@@ -253,7 +252,8 @@ readonly, format
253252
Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter
254253
MUST provide a writable buffer or else report failure. Otherwise, the
255254
exporter MAY provide either a read-only or writable buffer, but the choice
256-
MUST be consistent for all consumers.
255+
MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | PyBUF_WRITABLE`
256+
can be used to request a simple writable buffer.
257257

258258
.. c:macro:: PyBUF_FORMAT
259259
@@ -265,8 +265,9 @@ readonly, format
265265
Since :c:macro:`PyBUF_SIMPLE` is defined as 0, :c:macro:`PyBUF_WRITABLE`
266266
can be used as a stand-alone flag to request a simple writable buffer.
267267

268-
:c:macro:`PyBUF_FORMAT` can be \|'d to any of the flags except :c:macro:`PyBUF_SIMPLE`.
269-
The latter already implies format ``B`` (unsigned bytes).
268+
:c:macro:`PyBUF_FORMAT` must be \|'d to any of the flags except :c:macro:`PyBUF_SIMPLE`, because
269+
the latter already implies format ``B`` (unsigned bytes). :c:macro:`!PyBUF_FORMAT` cannot be
270+
used on its own.
270271

271272

272273
shape, strides, suboffsets

0 commit comments

Comments
 (0)
0