Skip to content

Commit f42e369

Browse files
authored
Merge branch 'python:main' into patch-1
2 parents 6d6f132 + e21754d commit f42e369

File tree

856 files changed

+22957
-8246
lines changed

Some content is hidden

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

856 files changed

+22957
-8246
lines changed

.cirrus-DISABLED.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/CODEOWNERS

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ configure* @erlend-aasland @corona10
2121
**/*context* @1st1
2222
**/*genobject* @markshannon
2323
**/*hamt* @1st1
24+
**/*jit* @brandtbucher
2425
Objects/set* @rhettinger
2526
Objects/dict* @methane @markshannon
2627
Objects/typevarobject.c @JelleZijlstra
@@ -37,11 +38,37 @@ Python/ast_opt.c @isidentical
3738
Python/bytecodes.c @markshannon @gvanrossum
3839
Python/optimizer*.c @markshannon @gvanrossum
3940
Lib/test/test_patma.py @brandtbucher
40-
Lib/test/test_peepholer.py @brandtbucher
4141
Lib/test/test_type_*.py @JelleZijlstra
4242
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
4343
Tools/c-analyzer/ @ericsnowcurrently
4444

45+
# dbm
46+
**/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
47+
48+
# runtime state/lifecycle
49+
**/*pylifecycle* @ericsnowcurrently
50+
**/*pystate* @ericsnowcurrently
51+
**/*preconfig* @ericsnowcurrently
52+
**/*initconfig* @ericsnowcurrently
53+
**/*pathconfig* @ericsnowcurrently
54+
**/*sysmodule* @ericsnowcurrently
55+
**/*bltinmodule* @ericsnowcurrently
56+
**/*gil* @ericsnowcurrently
57+
Include/internal/pycore_runtime.h @ericsnowcurrently
58+
Include/internal/pycore_interp.h @ericsnowcurrently
59+
Include/internal/pycore_tstate.h @ericsnowcurrently
60+
Include/internal/pycore_*_state.h @ericsnowcurrently
61+
Include/internal/pycore_*_init.h @ericsnowcurrently
62+
Include/internal/pycore_atexit.h @ericsnowcurrently
63+
Include/internal/pycore_freelist.h @ericsnowcurrently
64+
Include/internal/pycore_global_objects.h @ericsnowcurrently
65+
Include/internal/pycore_obmalloc.h @ericsnowcurrently
66+
Include/internal/pycore_pymem.h @ericsnowcurrently
67+
Modules/main.c @ericsnowcurrently
68+
Programs/_bootstrap_python.c @ericsnowcurrently
69+
Programs/python.c @ericsnowcurrently
70+
Tools/build/generate_global_objects.py @ericsnowcurrently
71+
4572
# Exceptions
4673
Lib/traceback.py @iritkatriel
4774
Lib/test/test_except*.py @iritkatriel
@@ -50,13 +77,13 @@ Objects/exceptions.c @iritkatriel
5077
Python/traceback.c @iritkatriel
5178

5279
# Hashing
53-
**/*hashlib* @tiran
54-
**/*pyhash* @tiran
55-
**/*sha* @tiran
56-
**/*md5* @tiran
57-
**/*blake* @tiran
58-
/Modules/_blake2/** @tiran
59-
/Modules/_sha3/** @tiran
80+
**/*hashlib* @gpshead @tiran
81+
**/*pyhash* @gpshead @tiran
82+
**/sha* @gpshead @tiran
83+
Modules/md5* @gpshead @tiran
84+
**/*blake* @gpshead @tiran
85+
Modules/_blake2/** @gpshead @tiran
86+
Modules/_hacl/** @gpshead
6087

6188
# logging
6289
**/*logging* @vsajip
@@ -76,7 +103,20 @@ Python/traceback.c @iritkatriel
76103
# Import (including importlib).
77104
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
78105
/Python/import.c @kumaraditya303
79-
**/*importlib/resources/* @jaraco @warsaw @FFY00
106+
Python/dynload_*.c @ericsnowcurrently
107+
**/*freeze* @ericsnowcurrently
108+
**/*frozen* @ericsnowcurrently
109+
**/*modsupport* @ericsnowcurrently
110+
**/*modulefinder* @ericsnowcurrently
111+
**/*moduleobject* @ericsnowcurrently
112+
**/*multiphase* @ericsnowcurrently
113+
**/*pkgutil* @ericsnowcurrently
114+
**/*pythonrun* @ericsnowcurrently
115+
**/*runpy* @ericsnowcurrently
116+
**/*singlephase* @ericsnowcurrently
117+
Lib/test/test_module/ @ericsnowcurrently
118+
Doc/c-api/module.rst @ericsnowcurrently
119+
**/*importlib/resources/* @jaraco @warsaw @FFY00
80120
**/importlib/metadata/* @jaraco @warsaw
81121

82122
# Dates and times
@@ -120,6 +160,9 @@ Lib/ast.py @isidentical
120160
/Lib/unittest/mock.py @cjw296
121161
/Lib/test/test_unittest/testmock/* @cjw296
122162

163+
# multiprocessing
164+
**/*multiprocessing* @gpshead
165+
123166
# SQLite 3
124167
**/*sqlite* @berkerpeksag @erlend-aasland
125168

@@ -192,6 +235,8 @@ Doc/c-api/stable.rst @encukou
192235
Doc/howto/clinic.rst @erlend-aasland
193236

194237
# Subinterpreters
238+
**/*interpreteridobject.* @ericsnowcurrently
239+
**/*crossinterp* @ericsnowcurrently
195240
Lib/test/support/interpreters/ @ericsnowcurrently
196241
Modules/_xx*interp*module.c @ericsnowcurrently
197242
Lib/test/test_interpreters/ @ericsnowcurrently

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ jobs:
142142
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
143143
- name: Configure ccache action
144144
uses: hendrikmuhs/[email protected]
145+
with:
146+
save: false
145147
- name: Check Autoconf and aclocal versions
146148
run: |
147149
grep "Generated by GNU Autoconf 2.71" configure
@@ -284,6 +286,8 @@ jobs:
284286
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
285287
- name: Configure ccache action
286288
uses: hendrikmuhs/[email protected]
289+
with:
290+
save: false
287291
- name: Configure CPython
288292
run: ./configure --config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
289293
- name: Build CPython
@@ -327,6 +331,8 @@ jobs:
327331
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
328332
- name: Configure ccache action
329333
uses: hendrikmuhs/[email protected]
334+
with:
335+
save: false
330336
- name: Setup directory envs for out-of-tree builds
331337
run: |
332338
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
@@ -446,6 +452,9 @@ jobs:
446452
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
447453
- name: Configure ccache action
448454
uses: hendrikmuhs/[email protected]
455+
with:
456+
save: ${{ github.event_name == 'push' }}
457+
max-size: "200M"
449458
- name: Configure CPython
450459
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
451460
- name: Build CPython

.github/workflows/build_msi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
strategy:
3333
matrix:
3434
type: [x86, x64, arm64]
35+
env:
36+
IncludeFreethreaded: true
3537
steps:
3638
- uses: actions/checkout@v4
3739
- name: Build CPython installer

.github/workflows/jit.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: JIT
2+
on:
3+
pull_request:
4+
paths: '**jit**'
5+
push:
6+
paths: '**jit**'
7+
workflow_dispatch:
8+
jobs:
9+
jit:
10+
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
11+
runs-on: ${{ matrix.runner }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
target:
16+
- i686-pc-windows-msvc/msvc
17+
- x86_64-pc-windows-msvc/msvc
18+
- x86_64-apple-darwin/clang
19+
- x86_64-unknown-linux-gnu/gcc
20+
- x86_64-unknown-linux-gnu/clang
21+
- aarch64-unknown-linux-gnu/gcc
22+
- aarch64-unknown-linux-gnu/clang
23+
debug:
24+
- true
25+
- false
26+
llvm:
27+
- 16
28+
include:
29+
- target: i686-pc-windows-msvc/msvc
30+
architecture: Win32
31+
runner: windows-latest
32+
compiler: msvc
33+
- target: x86_64-pc-windows-msvc/msvc
34+
architecture: x64
35+
runner: windows-latest
36+
compiler: msvc
37+
- target: x86_64-apple-darwin/clang
38+
architecture: x86_64
39+
runner: macos-latest
40+
compiler: clang
41+
exclude: test_embed
42+
- target: x86_64-unknown-linux-gnu/gcc
43+
architecture: x86_64
44+
runner: ubuntu-latest
45+
compiler: gcc
46+
- target: x86_64-unknown-linux-gnu/clang
47+
architecture: x86_64
48+
runner: ubuntu-latest
49+
compiler: clang
50+
- target: aarch64-unknown-linux-gnu/gcc
51+
architecture: aarch64
52+
runner: ubuntu-latest
53+
compiler: gcc
54+
# These fail because of emulation, not because of the JIT:
55+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
56+
- target: aarch64-unknown-linux-gnu/clang
57+
architecture: aarch64
58+
runner: ubuntu-latest
59+
compiler: clang
60+
# These fail because of emulation, not because of the JIT:
61+
exclude: test_unix_events test_init test_process_pool test_shutdown test_multiprocessing_fork test_cmd_line test_faulthandler test_os test_perf_profiler test_posix test_signal test_socket test_subprocess test_threading test_venv
62+
env:
63+
CC: ${{ matrix.compiler }}
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-python@v5
67+
with:
68+
python-version: '3.11'
69+
70+
- name: Windows
71+
if: runner.os == 'Windows'
72+
run: |
73+
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
74+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
75+
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
76+
77+
- name: macOS
78+
if: runner.os == 'macOS'
79+
run: |
80+
brew install llvm@${{ matrix.llvm }}
81+
export SDKROOT="$(xcrun --show-sdk-path)"
82+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
83+
make all --jobs 3
84+
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
85+
86+
- name: Native Linux
87+
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
88+
run: |
89+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
90+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
91+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
92+
make all --jobs 4
93+
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
94+
- name: Emulated Linux
95+
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
96+
run: |
97+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
98+
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
99+
./configure --prefix="$(pwd)/../build"
100+
make install --jobs 4
101+
make clean --jobs 4
102+
export HOST=${{ matrix.architecture }}-linux-gnu
103+
sudo apt install --yes "gcc-$HOST" qemu-user
104+
${{ !matrix.debug && matrix.compiler == 'clang' && './configure --enable-optimizations' || '' }}
105+
${{ !matrix.debug && matrix.compiler == 'clang' && 'make profile-run-stamp --jobs 4' || '' }}
106+
export CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}"
107+
export CPP="$CC --preprocess"
108+
export HOSTRUNNER=qemu-${{ matrix.architecture }}
109+
export QEMU_LD_PREFIX="/usr/$HOST"
110+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
111+
make all --jobs 4
112+
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3

.github/workflows/mypy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- "Tools/build/generate_sbom.py"
1313
- "Tools/cases_generator/**"
1414
- "Tools/clinic/**"
15+
- "Tools/jit/**"
1516
- "Tools/peg_generator/**"
1617
- "Tools/requirements-dev.txt"
1718
- "Tools/wasm/**"
@@ -38,6 +39,7 @@ jobs:
3839
"Tools/build/",
3940
"Tools/cases_generator",
4041
"Tools/clinic",
42+
"Tools/jit",
4143
"Tools/peg_generator",
4244
"Tools/wasm",
4345
]

.github/workflows/reusable-ubuntu.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
4242
- name: Configure ccache action
4343
uses: hendrikmuhs/[email protected]
44+
with:
45+
save: ${{ github.event_name == 'push' }}
46+
max-size: "200M"
4447
- name: Setup directory envs for out-of-tree builds
4548
run: |
4649
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV

.github/workflows/reusable-windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Display build info
2121
run: .\python.bat -m test.pythoninfo
2222
- name: Tests
23-
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci
23+
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
2424

2525
build_win_amd64:
2626
name: 'build and test (x64)'
@@ -37,7 +37,7 @@ jobs:
3737
- name: Display build info
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
40-
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci
40+
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
4141

4242
build_win_arm64:
4343
name: 'build (arm64)'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Tools/unicode/data/
126126
# hendrikmuhs/ccache-action@v1
127127
/.ccache
128128
/cross-build/
129+
/jit_stencils.h
129130
/platform
130131
/profile-clean-stamp
131132
/profile-run-stamp

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: sphinx-lint
3030
args: [--enable=default-role]
31-
files: ^Doc/|^Misc/NEWS.d/next/
31+
files: ^Doc/|^Misc/NEWS.d/
3232

3333
- repo: meta
3434
hooks:

Doc/c-api/complex.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,29 @@ Complex Numbers as Python Objects
117117
118118
Return the real part of *op* as a C :c:expr:`double`.
119119
120+
If *op* is not a Python complex number object but has a
121+
:meth:`~object.__complex__` method, this method will first be called to
122+
convert *op* to a Python complex number object. If :meth:`!__complex__` is
123+
not defined then it falls back to call :c:func:`PyFloat_AsDouble` and
124+
returns its result. Upon failure, this method returns ``-1.0``, so one
125+
should call :c:func:`PyErr_Occurred` to check for errors.
126+
127+
.. versionchanged:: 3.13
128+
Use :meth:`~object.__complex__` if available.
120129
121130
.. c:function:: double PyComplex_ImagAsDouble(PyObject *op)
122131
123132
Return the imaginary part of *op* as a C :c:expr:`double`.
124133
134+
If *op* is not a Python complex number object but has a
135+
:meth:`~object.__complex__` method, this method will first be called to
136+
convert *op* to a Python complex number object. If :meth:`!__complex__` is
137+
not defined then it falls back to call :c:func:`PyFloat_AsDouble` and
138+
returns ``0.0`` on success. Upon failure, this method returns ``-1.0``, so
139+
one should call :c:func:`PyErr_Occurred` to check for errors.
140+
141+
.. versionchanged:: 3.13
142+
Use :meth:`~object.__complex__` if available.
125143
126144
.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)
127145

0 commit comments

Comments
 (0)