Skip to content

Commit f400a11

Browse files
committed
Merge remote-tracking branch 'upstream/main' into perf/hashlib/mutex-135239
# Conflicts: # Modules/hmacmodule.c
2 parents 7fd1396 + b53b0c1 commit f400a11

122 files changed

Lines changed: 3835 additions & 1869 deletions

File tree

Some content is hidden

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

.github/CODEOWNERS

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Objects/type* @markshannon
3535
Objects/codeobject.c @markshannon
3636
Objects/frameobject.c @markshannon
3737
Objects/call.c @markshannon
38+
Objects/object.c @ZeroIntensity
3839
Python/ceval*.c @markshannon
3940
Python/ceval*.h @markshannon
4041
Python/codegen.c @markshannon @iritkatriel
@@ -44,8 +45,9 @@ Python/flowgraph.c @markshannon @iritkatriel
4445
Python/instruction_sequence.c @iritkatriel
4546
Python/bytecodes.c @markshannon
4647
Python/optimizer*.c @markshannon
47-
Python/optimizer_analysis.c @Fidget-Spinner
48-
Python/optimizer_bytecodes.c @Fidget-Spinner
48+
Python/optimizer_analysis.c @Fidget-Spinner @tomasr8
49+
Python/optimizer_bytecodes.c @Fidget-Spinner @tomasr8
50+
Python/optimizer_symbols.c @tomasr8
4951
Python/symtable.c @JelleZijlstra @carljm
5052
Lib/_pyrepl/* @pablogsal @lysnikolaou @ambv
5153
Lib/test/test_patma.py @brandtbucher
@@ -66,8 +68,8 @@ Doc/_static/** @AA-Turner @hugovk
6668
Doc/tools/** @AA-Turner @hugovk
6769

6870
# runtime state/lifecycle
69-
**/*pylifecycle* @ericsnowcurrently
70-
**/*pystate* @ericsnowcurrently
71+
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity
72+
**/*pystate* @ericsnowcurrently @ZeroIntensity
7173
**/*preconfig* @ericsnowcurrently
7274
**/*initconfig* @ericsnowcurrently
7375
**/*pathconfig* @ericsnowcurrently
@@ -187,13 +189,13 @@ Include/internal/pycore_time.h @pganssle @abalkin
187189
/Tools/cases_generator/ @markshannon
188190

189191
# AST
190-
Python/ast.c @isidentical @JelleZijlstra @eclips4
191-
Python/ast_preprocess.c @isidentical @eclips4
192-
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
193-
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
194-
Lib/ast.py @isidentical @JelleZijlstra @eclips4
195-
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4
196-
Lib/test/test_ast/ @eclips4
192+
Python/ast.c @isidentical @JelleZijlstra @eclips4 @tomasr8
193+
Python/ast_preprocess.c @isidentical @eclips4 @tomasr8
194+
Parser/asdl.py @isidentical @JelleZijlstra @eclips4 @tomasr8
195+
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4 @tomasr8
196+
Lib/ast.py @isidentical @JelleZijlstra @eclips4 @tomasr8
197+
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4 @tomasr8
198+
Lib/test/test_ast/ @eclips4 @tomasr8
197199

198200
# Mock
199201
/Lib/unittest/mock.py @cjw296
@@ -340,3 +342,6 @@ Modules/_xxtestfuzz/ @ammaraskar
340342
Python/remote_debug.h @pablogsal
341343
Python/remote_debugging.c @pablogsal
342344
Modules/_remote_debugging_module.c @pablogsal @ambv @1st1
345+
346+
# gettext
347+
**/*gettext* @tomasr8

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,14 @@ jobs:
527527
config_hash: ${{ needs.build-context.outputs.config-hash }}
528528
free-threading: ${{ matrix.free-threading }}
529529

530+
build-ubsan:
531+
name: Undefined behavior sanitizer
532+
needs: build-context
533+
if: needs.build-context.outputs.run-tests == 'true'
534+
uses: ./.github/workflows/reusable-ubsan.yml
535+
with:
536+
config_hash: ${{ needs.build-context.outputs.config-hash }}
537+
530538
cross-build-linux:
531539
name: Cross build Linux
532540
runs-on: ubuntu-latest
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Reusable Undefined Behavior Sanitizer
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
config_hash:
7+
required: true
8+
type: string
9+
10+
env:
11+
FORCE_COLOR: 1
12+
13+
jobs:
14+
build-ubsan-reusable:
15+
name: 'Undefined behavior sanitizer'
16+
runs-on: ubuntu-24.04
17+
timeout-minutes: 60
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
persist-credentials: false
22+
- name: Runner image version
23+
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
24+
- name: Restore config.cache
25+
uses: actions/cache@v4
26+
with:
27+
path: config.cache
28+
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
29+
- name: Install dependencies
30+
run: |
31+
sudo ./.github/workflows/posix-deps-apt.sh
32+
# Install clang-20
33+
wget https://apt.llvm.org/llvm.sh
34+
chmod +x llvm.sh
35+
sudo ./llvm.sh 20
36+
- name: UBSAN option setup
37+
run: |
38+
echo "UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1" >> "$GITHUB_ENV"
39+
echo "CC=clang" >> "$GITHUB_ENV"
40+
echo "CXX=clang++" >> "$GITHUB_ENV"
41+
- name: Add ccache to PATH
42+
run: |
43+
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
44+
- name: Configure ccache action
45+
uses: hendrikmuhs/ccache-action@v1.2
46+
with:
47+
save: ${{ github.event_name == 'push' }}
48+
max-size: "200M"
49+
- name: Configure CPython
50+
run: >-
51+
./configure
52+
--config-cache
53+
--with-undefined-behavior-sanitizer
54+
--with-pydebug
55+
- name: Set up UBSAN log after configuration
56+
run: |
57+
echo "UBSAN_OPTIONS=${UBSAN_OPTIONS}:log_path=${GITHUB_WORKSPACE}/ubsan_log" >> "$GITHUB_ENV"
58+
- name: Build CPython
59+
run: make -j4
60+
- name: Display build info
61+
run: make pythoninfo
62+
- name: Tests
63+
run: ./python -m test -j4
64+
- name: Display UBSAN logs
65+
if: always()
66+
run: find "${GITHUB_WORKSPACE}" -name 'ubsan_log.*' | xargs head -n 1000
67+
- name: Archive UBSAN logs
68+
if: always()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: >-
72+
ubsan-logs
73+
path: ubsan_log.*
74+
if-no-files-found: ignore

Doc/c-api/refcounting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ of Python objects.
210210
211211
Py_SETREF(dst, src);
212212
213-
That arranges to set *dst* to *src* _before_ releasing the reference
213+
That arranges to set *dst* to *src* *before* releasing the reference
214214
to the old value of *dst*, so that any code triggered as a side-effect
215215
of *dst* getting torn down no longer believes *dst* points
216216
to a valid object.

Doc/c-api/type.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ Type Objects
282282
and other places where a method's defining class cannot be passed using the
283283
:c:type:`PyCMethod` calling convention.
284284
285+
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
286+
and will be valid as long as you hold a reference to *type*.
287+
Do not release it with :c:func:`Py_DECREF` or similar.
288+
285289
.. versionadded:: 3.11
286290
287291
.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)

Doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
rst_epilog = f"""
8080
.. |python_version_literal| replace:: ``Python {version}``
8181
.. |python_x_dot_y_literal| replace:: ``python{version}``
82+
.. |python_x_dot_y_t_literal| replace:: ``python{version}t``
83+
.. |python_x_dot_y_t_literal_config| replace:: ``python{version}t-config``
84+
.. |x_dot_y_b2_literal| replace:: ``{version}.0b2``
85+
.. |applications_python_version_literal| replace:: ``/Applications/Python {version}/``
8286
.. |usr_local_bin_python_x_dot_y_literal| replace:: ``/usr/local/bin/python{version}``
8387
8488
.. Apparently this how you hack together a formatted link:

Doc/data/refcounts.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,10 @@ PyType_GetFlags:PyTypeObject*:type:0:
23852385
PyType_GetName:PyObject*::+1:
23862386
PyType_GetName:PyTypeObject*:type:0:
23872387

2388+
PyType_GetModuleByDef:PyObject*::0:
2389+
PyType_GetModuleByDef:PyTypeObject*:type:0:
2390+
PyType_GetModuleByDef:PyModuleDef*:def::
2391+
23882392
PyType_GetQualName:PyObject*::+1:
23892393
PyType_GetQualName:PyTypeObject*:type:0:
23902394

Doc/howto/free-threading-extensions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
C API Extension Support for Free Threading
77
******************************************
88

9-
Starting with the 3.13 release, CPython has experimental support for running
10-
with the :term:`global interpreter lock` (GIL) disabled in a configuration
9+
Starting with the 3.13 release, CPython has support for running with
10+
the :term:`global interpreter lock` (GIL) disabled in a configuration
1111
called :term:`free threading`. This document describes how to adapt C API
1212
extensions to support free threading.
1313

Doc/howto/free-threading-python.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
.. _freethreading-python-howto:
22

3-
**********************************************
4-
Python experimental support for free threading
5-
**********************************************
3+
*********************************
4+
Python support for free threading
5+
*********************************
66

7-
Starting with the 3.13 release, CPython has experimental support for a build of
7+
Starting with the 3.13 release, CPython has support for a build of
88
Python called :term:`free threading` where the :term:`global interpreter lock`
99
(GIL) is disabled. Free-threaded execution allows for full utilization of the
1010
available processing power by running threads in parallel on available CPU cores.
1111
While not all software will benefit from this automatically, programs
1212
designed with threading in mind will run faster on multi-core hardware.
1313

14-
**The free-threaded mode is experimental** and work is ongoing to improve it:
15-
expect some bugs and a substantial single-threaded performance hit.
14+
The free-threaded mode is working and continues to be improved, but
15+
there is some additional overhead in single-threaded workloads compared
16+
to the regular build. Additionally, third-party packages, in particular ones
17+
with an :term:`extension module`, may not be ready for use in a
18+
free-threaded build, and will re-enable the :term:`GIL`.
1619

1720
This document describes the implications of free threading
1821
for Python code. See :ref:`freethreading-extensions-howto` for information on
@@ -43,7 +46,7 @@ Identifying free-threaded Python
4346
================================
4447

4548
To check if the current interpreter supports free-threading, :option:`python -VV <-V>`
46-
and :data:`sys.version` contain "experimental free-threading build".
49+
and :data:`sys.version` contain "free-threading build".
4750
The new :func:`sys._is_gil_enabled` function can be used to check whether
4851
the GIL is actually disabled in the running process.
4952

Doc/howto/regex.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,9 @@ extension. This regular expression matches ``foo.bar`` and
10161016
Now, consider complicating the problem a bit; what if you want to match
10171017
filenames where the extension is not ``bat``? Some incorrect attempts:
10181018

1019-
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring
1019+
``.*[.][^b].*$``
1020+
1021+
The first attempt above tries to exclude ``bat`` by requiring
10201022
that the first character of the extension is not a ``b``. This is wrong,
10211023
because the pattern also doesn't match ``foo.bar``.
10221024

@@ -1043,7 +1045,9 @@ confusing.
10431045

10441046
A negative lookahead cuts through all this confusion:
10451047

1046-
``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat``
1048+
``.*[.](?!bat$)[^.]*$``
1049+
1050+
The negative lookahead means: if the expression ``bat``
10471051
doesn't match at this point, try the rest of the pattern; if ``bat$`` does
10481052
match, the whole pattern will fail. The trailing ``$`` is required to ensure
10491053
that something like ``sample.batch``, where the extension only starts with

0 commit comments

Comments
 (0)