Skip to content

Commit bc1225b

Browse files
committed
Merge in the main branch
2 parents 8991444 + 153b3f7 commit bc1225b

File tree

395 files changed

+16972
-4298
lines changed

Some content is hidden

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

395 files changed

+16972
-4298
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ jobs:
250250
251251
build_ubuntu_ssltests:
252252
name: 'Ubuntu SSL tests with OpenSSL'
253-
runs-on: ubuntu-20.04
253+
runs-on: ubuntu-22.04
254254
timeout-minutes: 60
255255
needs: check_source
256256
if: needs.check_source.outputs.run_tests == 'true'
@@ -316,7 +316,7 @@ jobs:
316316

317317
test_hypothesis:
318318
name: "Hypothesis tests on Ubuntu"
319-
runs-on: ubuntu-20.04
319+
runs-on: ubuntu-22.04
320320
timeout-minutes: 60
321321
needs: check_source
322322
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
@@ -429,7 +429,7 @@ jobs:
429429

430430
build_asan:
431431
name: 'Address sanitizer'
432-
runs-on: ubuntu-20.04
432+
runs-on: ubuntu-22.04
433433
timeout-minutes: 60
434434
needs: check_source
435435
if: needs.check_source.outputs.run_tests == 'true'

.github/workflows/jit.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,10 @@ jobs:
7575
architecture: aarch64
7676
runner: ubuntu-latest
7777
compiler: gcc
78-
# These fail because of emulation, not because of the JIT:
79-
exclude: test_pathlib test_posixpath 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 test_external_inspection
8078
- target: aarch64-unknown-linux-gnu/clang
8179
architecture: aarch64
8280
runner: ubuntu-latest
8381
compiler: clang
84-
# These fail because of emulation, not because of the JIT:
85-
exclude: test_pathlib test_posixpath 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 test_external_inspection
8682
env:
8783
CC: ${{ matrix.compiler }}
8884
steps:
@@ -97,7 +93,7 @@ jobs:
9793
choco upgrade llvm -y
9894
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
9995
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
100-
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
96+
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
10197
10298
# No PGO or tests (yet):
10399
- name: Emulated Windows
@@ -115,7 +111,7 @@ jobs:
115111
SDKROOT="$(xcrun --show-sdk-path)" \
116112
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
117113
make all --jobs 4
118-
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
114+
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
119115
120116
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
121117
- name: Native Linux
@@ -125,11 +121,12 @@ jobs:
125121
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
126122
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations' }}
127123
make all --jobs 4
128-
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
124+
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
129125
130126
# --with-lto has been removed temporarily as a result of an open issue in LLVM 18 (see https://github.com/llvm/llvm-project/issues/87553)
131127
- name: Emulated Linux
132128
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
129+
# The --ignorefile on ./python -m test is used to exclude tests known to fail when running on an emulated Linux.
133130
run: |
134131
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
135132
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
@@ -146,4 +143,4 @@ jobs:
146143
HOSTRUNNER=qemu-${{ matrix.architecture }} \
147144
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations ' }} --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
148145
make all --jobs 4
149-
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
146+
./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3

.github/workflows/mypy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
pull_request:
99
paths:
1010
- ".github/workflows/mypy.yml"
11+
- "Lib/_pyrepl/**"
1112
- "Lib/test/libregrtest/**"
1213
- "Tools/build/generate_sbom.py"
1314
- "Tools/cases_generator/**"
@@ -35,8 +36,9 @@ jobs:
3536
strategy:
3637
matrix:
3738
target: [
39+
"Lib/_pyrepl",
3840
"Lib/test/libregrtest",
39-
"Tools/build/",
41+
"Tools/build",
4042
"Tools/cases_generator",
4143
"Tools/clinic",
4244
"Tools/jit",

.github/workflows/reusable-macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
HOMEBREW_NO_INSTALL_CLEANUP: 1
2323
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2424
PYTHONSTRICTEXTENSIONBUILD: 1
25+
TERM: linux
2526
strategy:
2627
fail-fast: false
2728
matrix:

.github/workflows/reusable-ubuntu.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212
build_ubuntu_reusable:
1313
name: 'build and test'
1414
timeout-minutes: 60
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-22.04
1616
env:
1717
FORCE_COLOR: 1
1818
OPENSSL_VER: 3.0.13
1919
PYTHONSTRICTEXTENSIONBUILD: 1
20+
TERM: linux
2021
steps:
2122
- uses: actions/checkout@v4
2223
- name: Register gcc problem matcher

.github/workflows/reusable-wasi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build_wasi_reusable:
1010
name: 'build and test'
1111
timeout-minutes: 60
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
env:
1414
WASMTIME_VERSION: 18.0.3
1515
WASI_SDK_VERSION: 21

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ repos:
1111
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
1212
files: ^Tools/clinic/|Lib/test/test_clinic.py
1313

14+
- repo: https://github.com/psf/black-pre-commit-mirror
15+
rev: 24.4.2
16+
hooks:
17+
- id: black
18+
name: Run Black on Tools/jit/
19+
files: ^Tools/jit/
20+
language_version: python3.12
21+
1422
- repo: https://github.com/pre-commit/pre-commit-hooks
1523
rev: v4.5.0
1624
hooks:

Doc/c-api/frame.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,19 @@ See also :ref:`Reflection <reflection>`.
120120
121121
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame)
122122
123-
Get the *frame*'s :attr:`~frame.f_locals` attribute (:class:`dict`).
123+
Get the *frame*'s :attr:`~frame.f_locals` attribute.
124+
If the frame refers to a function or comprehension, this returns
125+
a write-through proxy object that allows modifying the locals.
126+
In all other cases (classes, modules) it returns the :class:`dict`
127+
representing the frame locals directly.
124128
125129
Return a :term:`strong reference`.
126130
127131
.. versionadded:: 3.11
128132
133+
.. versionchanged:: 3.13
134+
Return a proxy object for functions and comprehensions.
135+
129136
130137
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
131138

Doc/c-api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ document the API functions in detail.
2525
memory.rst
2626
objimpl.rst
2727
apiabiversion.rst
28+
monitoring.rst

Doc/c-api/init.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,58 @@ Python-level trace functions in previous versions.
19041904
19051905
.. versionadded:: 3.12
19061906
1907+
Reference tracing
1908+
=================
1909+
1910+
.. versionadded:: 3.13
1911+
1912+
.. c:type:: int (*PyRefTracer)(PyObject *, int event, void* data)
1913+
1914+
The type of the trace function registered using :c:func:`PyRefTracer_SetTracer`.
1915+
The first parameter is a Python object that has been just created (when **event**
1916+
is set to :c:data:`PyRefTracer_CREATE`) or about to be destroyed (when **event**
1917+
is set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer
1918+
that was provided when :c:func:`PyRefTracer_SetTracer` was called.
1919+
1920+
.. versionadded:: 3.13
1921+
1922+
.. c:var:: int PyRefTracer_CREATE
1923+
1924+
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
1925+
object has been created.
1926+
1927+
.. c:var:: int PyRefTracer_DESTROY
1928+
1929+
The value for the *event* parameter to :c:type:`PyRefTracer` functions when a Python
1930+
object has been destroyed.
1931+
1932+
.. c:function:: int PyRefTracer_SetTracer(PyRefTracer tracer, void *data)
1933+
1934+
Register a reference tracer function. The function will be called when a new
1935+
Python has been created or when an object is going to be destroyed. If
1936+
**data** is provided it must be an opaque pointer that will be provided when
1937+
the tracer function is called. Return ``0`` on success. Set an exception and
1938+
return ``-1`` on error.
1939+
1940+
Not that tracer functions **must not** create Python objects inside or
1941+
otherwise the call will be re-entrant. The tracer also **must not** clear
1942+
any existing exception or set an exception. The GIL will be held every time
1943+
the tracer function is called.
1944+
1945+
The GIL must be held when calling this function.
1946+
1947+
.. versionadded:: 3.13
1948+
1949+
.. c:function:: PyRefTracer PyRefTracer_GetTracer(void** data)
1950+
1951+
Get the registered reference tracer function and the value of the opaque data
1952+
pointer that was registered when :c:func:`PyRefTracer_SetTracer` was called.
1953+
If no tracer was registered this function will return NULL and will set the
1954+
**data** pointer to NULL.
1955+
1956+
The GIL must be held when calling this function.
1957+
1958+
.. versionadded:: 3.13
19071959
19081960
.. _advanced-debugging:
19091961

Doc/c-api/init_config.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,10 @@ PyConfig
12511251
for more information.
12521252
12531253
Set by :option:`-X perf <-X>` command line option and by the
1254-
:envvar:`PYTHONPERFSUPPORT` environment variable.
1254+
:envvar:`PYTHONPERFSUPPORT` environment variable for perf support
1255+
with stack pointers and :option:`-X perfjit <-X>` command line option
1256+
and by the :envvar:`PYTHONPERFJITSUPPORT` environment variable for perf
1257+
support with DWARF JIT information.
12551258
12561259
Default: ``-1``.
12571260

Doc/c-api/long.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
390390
Usage example::
391391
392392
int32_t value;
393-
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, &value, sizeof(value), -1);
393+
Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);
394394
if (bytes < 0) {
395395
// Failed. A Python exception was set with the reason.
396396
return NULL;
@@ -418,7 +418,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
418418
called twice: first to determine the buffer size, then to fill it::
419419
420420
// Ask how much space we need.
421-
Py_ssize_t expected = PyLong_AsNativeBits(pylong, NULL, 0, -1);
421+
Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);
422422
if (expected < 0) {
423423
// Failed. A Python exception was set with the reason.
424424
return NULL;
@@ -430,7 +430,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
430430
return NULL;
431431
}
432432
// Safely get the entire value.
433-
Py_ssize_t bytes = PyLong_AsNativeBits(pylong, bignum, expected, -1);
433+
Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);
434434
if (bytes < 0) { // Exception has been set.
435435
free(bignum);
436436
return NULL;

Doc/c-api/module.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,31 @@ The available slot types are:
411411
412412
.. versionadded:: 3.12
413413
414+
.. c:macro:: Py_mod_gil
415+
416+
Specifies one of the following values:
417+
418+
.. c:macro:: Py_MOD_GIL_USED
419+
420+
The module depends on the presence of the global interpreter lock (GIL),
421+
and may access global state without synchronization.
422+
423+
.. c:macro:: Py_MOD_GIL_NOT_USED
424+
425+
The module is safe to run without an active GIL.
426+
427+
This slot is ignored by Python builds not configured with
428+
:option:`--disable-gil`. Otherwise, it determines whether or not importing
429+
this module will cause the GIL to be automatically enabled. See
430+
:envvar:`PYTHON_GIL` and :option:`-X gil <-X>` for more detail.
431+
432+
Multiple ``Py_mod_gil`` slots may not be specified in one module definition.
433+
434+
If ``Py_mod_gil`` is not specified, the import machinery defaults to
435+
``Py_MOD_GIL_USED``.
436+
437+
.. versionadded: 3.13
438+
414439
See :PEP:`489` for more details on multi-phase initialization.
415440
416441
Low-level module creation functions
@@ -609,6 +634,19 @@ state:
609634
610635
.. versionadded:: 3.9
611636
637+
.. c:function:: int PyModule_ExperimentalSetGIL(PyObject *module, void *gil)
638+
639+
Indicate that *module* does or does not support running without the global
640+
interpreter lock (GIL), using one of the values from
641+
:c:macro:`Py_mod_gil`. It must be called during *module*'s initialization
642+
function. If this function is not called during module initialization, the
643+
import machinery assumes the module does not support running without the
644+
GIL. This function is only available in Python builds configured with
645+
:option:`--disable-gil`.
646+
Return ``-1`` on error, ``0`` on success.
647+
648+
.. versionadded:: 3.13
649+
612650
613651
Module lookup
614652
^^^^^^^^^^^^^

0 commit comments

Comments
 (0)