Skip to content

Commit ba534be

Browse files
committed
Merge branch 'main' into monitoring-branch-taken
2 parents 8fc38dd + e256a75 commit ba534be

File tree

774 files changed

+49676
-35664
lines changed

Some content is hidden

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

774 files changed

+49676
-35664
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/CODEOWNERS

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ Objects/frameobject.c @markshannon
3333
Objects/call.c @markshannon
3434
Python/ceval*.c @markshannon
3535
Python/ceval*.h @markshannon
36+
Python/codegen.c @markshannon @iritkatriel
3637
Python/compile.c @markshannon @iritkatriel
3738
Python/assemble.c @markshannon @iritkatriel
3839
Python/flowgraph.c @markshannon @iritkatriel
3940
Python/instruction_sequence.c @iritkatriel
40-
Python/ast_opt.c @isidentical
4141
Python/bytecodes.c @markshannon
4242
Python/optimizer*.c @markshannon
4343
Python/optimizer_analysis.c @Fidget-Spinner
@@ -157,10 +157,12 @@ Include/internal/pycore_time.h @pganssle @abalkin
157157
/Tools/cases_generator/ @markshannon
158158

159159
# AST
160-
Python/ast.c @isidentical @JelleZijlstra
161-
Parser/asdl.py @isidentical @JelleZijlstra
162-
Parser/asdl_c.py @isidentical @JelleZijlstra
163-
Lib/ast.py @isidentical @JelleZijlstra
160+
Python/ast.c @isidentical @JelleZijlstra @eclips4
161+
Python/ast_opt.c @isidentical @eclips4
162+
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
163+
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
164+
Lib/ast.py @isidentical @JelleZijlstra @eclips4
165+
Lib/test/test_ast/ @eclips4
164166

165167
# Mock
166168
/Lib/unittest/mock.py @cjw296
@@ -211,8 +213,9 @@ Doc/c-api/stable.rst @encukou
211213

212214
**/*ensurepip* @pfmoore @pradyunsg
213215

214-
**/*idlelib* @terryjreedy
215216
/Doc/library/idle.rst @terryjreedy
217+
**/*idlelib* @terryjreedy
218+
**/*turtledemo* @terryjreedy
216219

217220
**/*annotationlib* @JelleZijlstra
218221
**/*typing* @JelleZijlstra @AlexWaygood
@@ -275,3 +278,6 @@ Lib/test/test_interpreters/ @ericsnowcurrently
275278
# Config Parser
276279
Lib/configparser.py @jaraco
277280
Lib/test/test_configparser.py @jaraco
281+
282+
# Doc sections
283+
Doc/reference/ @willingc

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
strategy:
203203
fail-fast: false
204204
matrix:
205-
openssl_ver: [1.1.1w, 3.0.13, 3.1.5, 3.2.1]
205+
openssl_ver: [3.0.15, 3.1.7, 3.2.3, 3.3.2]
206206
env:
207207
OPENSSL_VER: ${{ matrix.openssl_ver }}
208208
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -266,7 +266,7 @@ jobs:
266266
needs: check_source
267267
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
268268
env:
269-
OPENSSL_VER: 3.0.13
269+
OPENSSL_VER: 3.0.15
270270
PYTHONSTRICTEXTENSIONBUILD: 1
271271
steps:
272272
- uses: actions/checkout@v4
@@ -380,7 +380,7 @@ jobs:
380380
needs: check_source
381381
if: needs.check_source.outputs.run_tests == 'true'
382382
env:
383-
OPENSSL_VER: 3.0.13
383+
OPENSSL_VER: 3.0.15
384384
PYTHONSTRICTEXTENSIONBUILD: 1
385385
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
386386
steps:

.github/workflows/reusable-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1212
cancel-in-progress: true
1313

14+
env:
15+
FORCE_COLOR: 1
16+
1417
jobs:
1518
build_doc:
1619
name: 'Docs'

.github/workflows/reusable-macos.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
path: config.cache
3636
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
3737
- name: Install Homebrew dependencies
38-
run: brew install pkg-config [email protected] xz gdbm tcl-tk
38+
run: brew install pkg-config [email protected] xz gdbm tcl-tk make
3939
- name: Configure CPython
4040
run: |
4141
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
@@ -44,14 +44,27 @@ jobs:
4444
--config-cache \
4545
--with-pydebug \
4646
--enable-slower-safety \
47+
--enable-safety \
4748
${{ inputs.free-threading && '--disable-gil' || '' }} \
4849
--prefix=/opt/python-dev \
4950
--with-openssl="$(brew --prefix [email protected])"
5051
- name: Build CPython
51-
run: set -o pipefail; make -j8 2>&1 | tee compiler_output.txt
52+
if : ${{ inputs.free-threading || inputs.os != 'macos-13' }}
53+
run: gmake -j8
54+
- name: Build CPython for compiler warning check
55+
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
56+
run: set -o pipefail; gmake -j8 --output-sync 2>&1 | tee compiler_output_macos.txt
5257
- name: Display build info
5358
run: make pythoninfo
5459
- name: Check compiler warnings
55-
run: python3 Tools/build/check_warnings.py --compiler-output-file-path=compiler_output.txt --warning-ignore-file-path=Tools/build/.warningignore_macos --compiler-output-type=clang
60+
if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }}
61+
run: >-
62+
python3 Tools/build/check_warnings.py
63+
--compiler-output-file-path=compiler_output_macos.txt
64+
--warning-ignore-file-path=Tools/build/.warningignore_macos
65+
--compiler-output-type=clang
66+
--fail-on-regression
67+
--fail-on-improvement
68+
--path-prefix="./"
5669
- name: Tests
5770
run: make test

.github/workflows/reusable-ubuntu.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-22.04
1818
env:
1919
FORCE_COLOR: 1
20-
OPENSSL_VER: 3.0.13
20+
OPENSSL_VER: 3.0.15
2121
PYTHONSTRICTEXTENSIONBUILD: 1
2222
TERM: linux
2323
steps:
@@ -67,20 +67,33 @@ jobs:
6767
working-directory: ${{ env.CPYTHON_BUILDDIR }}
6868
run: >-
6969
../cpython-ro-srcdir/configure
70-
CFLAGS="-fdiagnostics-format=json"
7170
--config-cache
7271
--with-pydebug
7372
--enable-slower-safety
73+
--enable-safety
7474
--with-openssl=$OPENSSL_DIR
7575
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
7676
- name: Build CPython out-of-tree
77+
if: ${{ inputs.free-threading }}
7778
working-directory: ${{ env.CPYTHON_BUILDDIR }}
78-
run: set -o pipefail; make -j4 2>&1 | tee compiler_output.txt
79+
run: make -j4
80+
- name: Build CPython out-of-tree (for compiler warning check)
81+
if: ${{ !inputs.free-threading}}
82+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
83+
run: set -o pipefail; make -j4 --output-sync 2>&1 | tee compiler_output_ubuntu.txt
7984
- name: Display build info
8085
working-directory: ${{ env.CPYTHON_BUILDDIR }}
8186
run: make pythoninfo
8287
- name: Check compiler warnings
83-
run: python Tools/build/check_warnings.py --compiler-output-file-path=${{ env.CPYTHON_BUILDDIR }}/compiler_output.txt --warning-ignore-file-path ${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu --compiler-output-type=json
88+
if: ${{ !inputs.free-threading }}
89+
run: >-
90+
python Tools/build/check_warnings.py
91+
--compiler-output-file-path=${{ env.CPYTHON_BUILDDIR }}/compiler_output_ubuntu.txt
92+
--warning-ignore-file-path ${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu
93+
--compiler-output-type=gcc
94+
--fail-on-regression
95+
--fail-on-improvement
96+
--path-prefix="../cpython-ro-srcdir/"
8497
- name: Remount sources writable for tests
8598
# some tests write to srcdir, lack of pyc files slows down testing
8699
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw

.pre-commit-config.yaml

Lines changed: 13 additions & 4 deletions
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/
@@ -10,6 +10,10 @@ repos:
1010
name: Run Ruff (lint) on Lib/test/
1111
args: [--exit-non-zero-on-fix]
1212
files: ^Lib/test/
13+
- id: ruff
14+
name: Run Ruff (lint) on Tools/build/check_warnings.py
15+
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
16+
files: ^Tools/build/check_warnings.py
1317
- id: ruff
1418
name: Run Ruff (lint) on Argument Clinic
1519
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
@@ -20,15 +24,20 @@ repos:
2024
files: ^Doc/
2125

2226
- repo: https://github.com/psf/black-pre-commit-mirror
23-
rev: 24.4.2
27+
rev: 24.8.0
2428
hooks:
29+
- id: black
30+
name: Run Black on Tools/build/check_warnings.py
31+
files: ^Tools/build/check_warnings.py
32+
language_version: python3.12
33+
args: [--line-length=79]
2534
- id: black
2635
name: Run Black on Tools/jit/
2736
files: ^Tools/jit/
2837
language_version: python3.12
2938

3039
- repo: https://github.com/pre-commit/pre-commit-hooks
31-
rev: v4.5.0
40+
rev: v4.6.0
3241
hooks:
3342
- id: check-case-conflict
3443
- id: check-merge-conflict
@@ -42,7 +51,7 @@ repos:
4251
types_or: [c, inc, python, rst]
4352

4453
- repo: https://github.com/sphinx-contrib/sphinx-lint
45-
rev: v0.9.1
54+
rev: v1.0.0
4655
hooks:
4756
- id: sphinx-lint
4857
args: [--enable=default-role]

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: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def make_build_python(context):
138138

139139
def unpack_deps(host):
140140
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
141-
for name_ver in ["bzip2-1.0.8-1", "libffi-3.4.4-2", "openssl-3.0.13-1",
141+
for name_ver in ["bzip2-1.0.8-1", "libffi-3.4.4-2", "openssl-3.0.15-0",
142142
"sqlite-3.45.1-0", "xz-5.4.6-0"]:
143143
filename = f"{name_ver}-{host}.tar.gz"
144144
download(f"{deps_url}/{name_ver}/{filename}")
@@ -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/c/main_activity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToL
100100
}
101101

102102

103-
// --- Python intialization ----------------------------------------------------
103+
// --- Python initialization ---------------------------------------------------
104104

105105
static PyStatus set_config_string(
106106
JNIEnv *env, PyConfig *config, wchar_t **config_str, jstring value

0 commit comments

Comments
 (0)