Skip to content

Commit 2ce8ec7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into gh-141510-fix
2 parents 55f149c + 4c95ad8 commit 2ce8ec7

File tree

108 files changed

+5926
-3495
lines changed

Some content is hidden

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

108 files changed

+5926
-3495
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,17 @@ Programs/_bootstrap_python.c @ericsnowcurrently
289289
Programs/python.c @ericsnowcurrently
290290

291291
# JIT
292+
.github/workflows/jit.yml @savannahostrowski
292293
Include/internal/pycore_jit.h @brandtbucher @savannahostrowski @diegorusso
293294
Python/jit.c @brandtbucher @savannahostrowski @diegorusso
294295
Tools/jit/ @brandtbucher @savannahostrowski @diegorusso
295296
InternalDocs/jit.md @brandtbucher @savannahostrowski @diegorusso @AA-Turner
296297

297298
# Lazy imports (PEP 810)
298-
Objects/lazyimportobject.c @twouters @DinoV @pablogsal
299-
Include/internal/pycore_lazyimportobject.h @twouters @DinoV @pablogsal
300-
Lib/test/test_import/test_lazy_imports.py @twouters @DinoV @pablogsal
301-
Lib/test/test_import/data/lazy_imports/ @twouters @DinoV @pablogsal
299+
Objects/lazyimportobject.c @yhg1s @DinoV @pablogsal
300+
Include/internal/pycore_lazyimportobject.h @yhg1s @DinoV @pablogsal
301+
Lib/test/test_import/test_lazy_imports.py @yhg1s @DinoV @pablogsal
302+
Lib/test/test_import/data/lazy_imports/ @yhg1s @DinoV @pablogsal
302303

303304
# Micro-op / μop / Tier 2 Optimiser
304305
Python/optimizer.c @markshannon @Fidget-Spinner

.github/workflows/jit.yml

Lines changed: 88 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: JIT
22
on:
33
pull_request:
4-
paths:
4+
paths: &paths
55
- '**jit**'
66
- 'Python/bytecodes.c'
77
- 'Python/optimizer*.c'
@@ -12,16 +12,7 @@ on:
1212
- '!**/*.md'
1313
- '!**/*.ini'
1414
push:
15-
paths:
16-
- '**jit**'
17-
- 'Python/bytecodes.c'
18-
- 'Python/optimizer*.c'
19-
- 'Python/executor_cases.c.h'
20-
- 'Python/optimizer_cases.c.h'
21-
- '**_testinternalcapi**'
22-
- '!Python/perf_jit_trampoline.c'
23-
- '!**/*.md'
24-
- '!**/*.ini'
15+
paths: *paths
2516
workflow_dispatch:
2617

2718
permissions:
@@ -33,12 +24,13 @@ concurrency:
3324

3425
env:
3526
FORCE_COLOR: 1
27+
LLVM_VERSION: 21
3628

3729
jobs:
3830
interpreter:
3931
name: Interpreter (Debug)
4032
runs-on: ubuntu-24.04
41-
timeout-minutes: 90
33+
timeout-minutes: 60
4234
steps:
4335
- uses: actions/checkout@v6
4436
with:
@@ -50,27 +42,22 @@ jobs:
5042
- name: Test tier two interpreter
5143
run: |
5244
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
53-
jit:
45+
46+
windows:
5447
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
55-
needs: interpreter
48+
5649
runs-on: ${{ matrix.runner }}
57-
timeout-minutes: 90
50+
timeout-minutes: 60
5851
strategy:
5952
fail-fast: false
6053
matrix:
6154
target:
6255
- i686-pc-windows-msvc/msvc
6356
- x86_64-pc-windows-msvc/msvc
6457
- aarch64-pc-windows-msvc/msvc
65-
- x86_64-apple-darwin/clang
66-
- aarch64-apple-darwin/clang
67-
- x86_64-unknown-linux-gnu/gcc
68-
- aarch64-unknown-linux-gnu/gcc
6958
debug:
7059
- true
7160
- false
72-
llvm:
73-
- 21
7461
include:
7562
- target: i686-pc-windows-msvc/msvc
7663
architecture: Win32
@@ -81,131 +68,137 @@ jobs:
8168
- target: aarch64-pc-windows-msvc/msvc
8269
architecture: ARM64
8370
runner: windows-11-arm
84-
- target: x86_64-apple-darwin/clang
85-
architecture: x86_64
86-
runner: macos-15-intel
87-
- target: aarch64-apple-darwin/clang
88-
architecture: aarch64
89-
runner: macos-14
90-
- target: x86_64-unknown-linux-gnu/gcc
91-
architecture: x86_64
92-
runner: ubuntu-24.04
93-
- target: aarch64-unknown-linux-gnu/gcc
94-
architecture: aarch64
95-
runner: ubuntu-24.04-arm
9671
steps:
9772
- uses: actions/checkout@v6
9873
with:
9974
persist-credentials: false
10075
- uses: actions/setup-python@v6
10176
with:
10277
python-version: '3.11'
103-
10478
# PCbuild downloads LLVM automatically:
105-
- name: Windows
106-
if: runner.os == 'Windows'
79+
- name: Build
10780
run: |
10881
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
109-
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
110-
111-
- name: macOS
112-
if: runner.os == 'macOS'
82+
- name: Test
11383
run: |
114-
brew update
115-
brew install llvm@${{ matrix.llvm }}
116-
export SDKROOT="$(xcrun --show-sdk-path)"
117-
# Set MACOSX_DEPLOYMENT_TARGET and -Werror=unguarded-availability to
118-
# make sure we don't break downstream distributors (like uv):
119-
export CFLAGS_JIT='-Werror=unguarded-availability'
120-
export MACOSX_DEPLOYMENT_TARGET=10.15
121-
./configure --enable-experimental-jit --enable-universalsdk --with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }}
122-
make all --jobs 4
123-
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
84+
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
12485
125-
- name: Linux
126-
if: runner.os == 'Linux'
127-
run: |
128-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
129-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
130-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
131-
make all --jobs 4
132-
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
86+
macos:
87+
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
13388

134-
jit-with-disabled-gil:
135-
name: Free-Threaded (Debug)
136-
needs: interpreter
137-
runs-on: ubuntu-24.04
138-
timeout-minutes: 90
89+
runs-on: ${{ matrix.runner }}
90+
timeout-minutes: 60
13991
strategy:
14092
fail-fast: false
14193
matrix:
142-
llvm:
143-
- 21
94+
target:
95+
- x86_64-apple-darwin/clang
96+
- aarch64-apple-darwin/clang
97+
debug:
98+
- true
99+
- false
100+
include:
101+
- target: x86_64-apple-darwin/clang
102+
runner: macos-15-intel
103+
- target: aarch64-apple-darwin/clang
104+
runner: macos-14
144105
steps:
145106
- uses: actions/checkout@v6
146107
with:
147108
persist-credentials: false
148109
- uses: actions/setup-python@v6
149110
with:
150111
python-version: '3.11'
151-
- name: Build with JIT enabled and GIL disabled
112+
- name: Install LLVM
113+
run: |
114+
brew update
115+
brew install llvm@${{ env.LLVM_VERSION }}
116+
- name: Build
152117
run: |
153-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
154-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
155-
./configure --enable-experimental-jit --with-pydebug --disable-gil
118+
export SDKROOT="$(xcrun --show-sdk-path)"
119+
# Set MACOSX_DEPLOYMENT_TARGET and -Werror=unguarded-availability to
120+
# make sure we don't break downstream distributors (like uv):
121+
export CFLAGS_JIT='-Werror=unguarded-availability'
122+
export MACOSX_DEPLOYMENT_TARGET=10.15
123+
./configure --enable-experimental-jit --enable-universalsdk --with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }}
156124
make all --jobs 4
157-
- name: Run tests
125+
- name: Test
158126
run: |
159-
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
160-
continue-on-error: true
127+
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
161128
162-
no-opt-jit:
163-
name: JIT without optimizations (Debug)
164-
needs: interpreter
165-
runs-on: ubuntu-24.04
166-
timeout-minutes: 90
129+
linux:
130+
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
131+
132+
runs-on: ${{ matrix.runner }}
133+
timeout-minutes: 60
167134
strategy:
168135
fail-fast: false
169136
matrix:
170-
llvm:
171-
- 21
137+
target:
138+
- x86_64-unknown-linux-gnu/gcc
139+
- aarch64-unknown-linux-gnu/gcc
140+
debug:
141+
- true
142+
- false
143+
include:
144+
- target: x86_64-unknown-linux-gnu/gcc
145+
runner: ubuntu-24.04
146+
- target: aarch64-unknown-linux-gnu/gcc
147+
runner: ubuntu-24.04-arm
172148
steps:
173149
- uses: actions/checkout@v6
174150
with:
175151
persist-credentials: false
176152
- uses: actions/setup-python@v6
177153
with:
178154
python-version: '3.11'
179-
- name: Build with JIT
155+
- name: Build
180156
run: |
181-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
182-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
183-
./configure --enable-experimental-jit --with-pydebug
157+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ env.LLVM_VERSION }}
158+
export PATH="$(llvm-config-${{ env.LLVM_VERSION }} --bindir):$PATH"
159+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
184160
make all --jobs 4
185-
- name: Run tests without optimizations
161+
- name: Test
186162
run: |
187-
PYTHON_UOPS_OPTIMIZE=0 ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
163+
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
164+
165+
linux-extras:
166+
name: ${{ matrix.name }}
188167

189-
tail-call-jit:
190-
name: JIT with tail calling interpreter
191-
needs: interpreter
192168
runs-on: ubuntu-24.04
193-
timeout-minutes: 90
169+
timeout-minutes: 60
194170
strategy:
195171
fail-fast: false
196172
matrix:
197-
llvm:
198-
- 21
173+
include:
174+
- name: Free-Threaded (Debug)
175+
configure_flags: --enable-experimental-jit --with-pydebug --disable-gil
176+
continue_on_error: true
177+
- name: JIT without optimizations (Debug)
178+
configure_flags: --enable-experimental-jit --with-pydebug
179+
test_env: "PYTHON_UOPS_OPTIMIZE=0"
180+
- name: JIT with tail calling interpreter
181+
configure_flags: --enable-experimental-jit --with-tail-call-interp --with-pydebug
182+
use_clang: true
183+
run_tests: false
199184
steps:
200185
- uses: actions/checkout@v6
201186
with:
202187
persist-credentials: false
203188
- uses: actions/setup-python@v6
204189
with:
205190
python-version: '3.11'
206-
- name: Build with JIT and tailcall
191+
- name: Build
207192
run: |
208-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
209-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
210-
CC=clang-${{ matrix.llvm }} ./configure --enable-experimental-jit --with-tail-call-interp --with-pydebug
193+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ env.LLVM_VERSION }}
194+
export PATH="$(llvm-config-${{ env.LLVM_VERSION }} --bindir):$PATH"
195+
if [ "${{ matrix.use_clang }}" = "true" ]; then
196+
export CC=clang-${{ env.LLVM_VERSION }}
197+
fi
198+
./configure ${{ matrix.configure_flags }}
211199
make all --jobs 4
200+
- name: Test
201+
if: matrix.run_tests != false
202+
run: |
203+
${{ matrix.test_env }} ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
204+
continue-on-error: ${{ matrix.continue_on_error }}

Doc/c-api/dict.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Dictionary objects
5858
5959
Empty an existing dictionary of all key-value pairs.
6060
61+
Do nothing if the argument is not a :class:`dict` or a :class:`!dict`
62+
subclass.
63+
6164
6265
.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key)
6366

Doc/c-api/exceptions.rst

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -673,28 +673,46 @@ Signal Handling
673673
single: SIGINT (C macro)
674674
single: KeyboardInterrupt (built-in exception)
675675
676-
This function interacts with Python's signal handling.
676+
Handle external interruptions, such as signals or activating a debugger,
677+
whose processing has been delayed until it is safe
678+
to run Python code and/or raise exceptions.
677679
678-
If the function is called from the main thread and under the main Python
679-
interpreter, it checks whether a signal has been sent to the processes
680-
and if so, invokes the corresponding signal handler. If the :mod:`signal`
681-
module is supported, this can invoke a signal handler written in Python.
680+
For example, pressing :kbd:`Ctrl-C` causes a terminal to send the
681+
:py:data:`signal.SIGINT` signal.
682+
This function executes the corresponding Python signal handler, which,
683+
by default, raises the :exc:`KeyboardInterrupt` exception.
682684
683-
The function attempts to handle all pending signals, and then returns ``0``.
684-
However, if a Python signal handler raises an exception, the error
685-
indicator is set and the function returns ``-1`` immediately (such that
686-
other pending signals may not have been handled yet: they will be on the
687-
next :c:func:`PyErr_CheckSignals()` invocation).
685+
:c:func:`!PyErr_CheckSignals` should be called by long-running C code
686+
frequently enough so that the response appears immediate to humans.
688687
689-
If the function is called from a non-main thread, or under a non-main
690-
Python interpreter, it does nothing and returns ``0``.
688+
Handlers invoked by this function currently include:
691689
692-
This function can be called by long-running C code that wants to
693-
be interruptible by user requests (such as by pressing Ctrl-C).
690+
- Signal handlers, including Python functions registered using
691+
the :mod:`signal` module.
694692
695-
.. note::
696-
The default Python signal handler for :c:macro:`!SIGINT` raises the
697-
:exc:`KeyboardInterrupt` exception.
693+
Signal handlers are only run in the main thread of the main interpreter.
694+
695+
(This is where the function got the name: originally, signals
696+
were the only way to interrupt the interpreter.)
697+
698+
- Running the garbage collector, if necessary.
699+
700+
- Executing a pending :ref:`remote debugger <remote-debugging>` script.
701+
702+
If any handler raises an exception, immediately return ``-1`` with that
703+
exception set.
704+
Any remaining interruptions are left to be processed on the next
705+
:c:func:`PyErr_CheckSignals()` invocation, if appropriate.
706+
707+
If all handlers finish successfully, or there are no handlers to run,
708+
return ``0``.
709+
710+
.. versionchanged:: 3.12
711+
This function may now invoke the garbage collector.
712+
713+
.. versionchanged:: 3.14
714+
This function may now execute a remote debugger script, if remote
715+
debugging is enabled.
698716
699717
700718
.. c:function:: void PyErr_SetInterrupt()

0 commit comments

Comments
 (0)