Skip to content

Commit c87fcaa

Browse files
committed
Merge branch 'main' into incremental-gc-3
2 parents 8caba5d + 039d20a commit c87fcaa

File tree

408 files changed

+9773
-5855
lines changed

Some content is hidden

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

408 files changed

+9773
-5855
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM docker.io/library/fedora:37
22

33
ENV CC=clang
44

5-
ENV WASI_SDK_VERSION=20
5+
ENV WASI_SDK_VERSION=21
66
ENV WASI_SDK_PATH=/opt/wasi-sdk
77

88
ENV WASMTIME_HOME=/opt/wasmtime
9-
ENV WASMTIME_VERSION=18.0.2
9+
ENV WASMTIME_VERSION=18.0.3
1010
ENV WASMTIME_CPU_ARCH=x86_64
1111

1212
RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \

.github/workflows/build.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
- name: Get a list of the changed documentation-related files
9898
if: github.event_name == 'pull_request'
9999
id: changed-docs-files
100-
uses: Ana06/get-changed-files@v2.2.0
100+
uses: Ana06/get-changed-files@v2.3.0
101101
with:
102102
filter: |
103103
Doc/**
@@ -206,6 +206,8 @@ jobs:
206206
uses: ./.github/workflows/reusable-macos.yml
207207
with:
208208
config_hash: ${{ needs.check_source.outputs.config_hash }}
209+
# macos-14 is M1, macos-13 is Intel
210+
os-matrix: '["macos-14", "macos-13"]'
209211

210212
build_macos_free_threading:
211213
name: 'macOS (free-threading)'
@@ -215,6 +217,8 @@ jobs:
215217
with:
216218
config_hash: ${{ needs.check_source.outputs.config_hash }}
217219
free-threading: true
220+
# macos-14 is M1
221+
os-matrix: '["macos-14"]'
218222

219223
build_ubuntu:
220224
name: 'Ubuntu'
@@ -480,6 +484,24 @@ jobs:
480484
- name: Tests
481485
run: xvfb-run make test
482486

487+
build_tsan:
488+
name: 'Thread sanitizer'
489+
needs: check_source
490+
if: needs.check_source.outputs.run_tests == 'true'
491+
uses: ./.github/workflows/reusable-tsan.yml
492+
with:
493+
config_hash: ${{ needs.check_source.outputs.config_hash }}
494+
options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
495+
496+
build_tsan_free_threading:
497+
name: 'Thread sanitizer (free-threading)'
498+
needs: check_source
499+
if: needs.check_source.outputs.run_tests == 'true'
500+
uses: ./.github/workflows/reusable-tsan.yml
501+
with:
502+
config_hash: ${{ needs.check_source.outputs.config_hash }}
503+
options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
504+
483505
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
484506
cifuzz:
485507
name: CIFuzz
@@ -538,6 +560,8 @@ jobs:
538560
- build_windows_free_threading
539561
- test_hypothesis
540562
- build_asan
563+
- build_tsan
564+
- build_tsan_free_threading
541565
- cifuzz
542566

543567
runs-on: ubuntu-latest
@@ -571,6 +595,8 @@ jobs:
571595
build_windows,
572596
build_windows_free_threading,
573597
build_asan,
598+
build_tsan,
599+
build_tsan_free_threading,
574600
'
575601
|| ''
576602
}}

.github/workflows/jit.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ jobs:
108108
if: runner.os == 'macOS'
109109
run: |
110110
brew install llvm@${{ matrix.llvm }}
111-
export SDKROOT="$(xcrun --show-sdk-path)"
112-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
111+
SDKROOT="$(xcrun --show-sdk-path)" \
112+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
113113
make all --jobs 4
114114
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
115115
@@ -134,10 +134,10 @@ jobs:
134134
sudo apt install --yes "gcc-$HOST" qemu-user
135135
${{ !matrix.debug && matrix.compiler == 'clang' && './configure --enable-optimizations' || '' }}
136136
${{ !matrix.debug && matrix.compiler == 'clang' && 'make profile-run-stamp --jobs 4' || '' }}
137-
export CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}"
138-
export CPP="$CC --preprocess"
139-
export HOSTRUNNER=qemu-${{ matrix.architecture }}
140137
export QEMU_LD_PREFIX="/usr/$HOST"
141-
./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
138+
CC="${{ matrix.compiler == 'clang' && 'clang --target=$HOST' || '$HOST-gcc' }}" \
139+
CPP="$CC --preprocess" \
140+
HOSTRUNNER=qemu-${{ matrix.architecture }} \
141+
./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
142142
make all --jobs 4
143143
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
- uses: actions/setup-python@v5
2424
with:
2525
python-version: "3.x"
26-
- uses: pre-commit/[email protected].0
26+
- uses: pre-commit/[email protected].1

.github/workflows/project-updater.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- { project: 32, label: sprint }
2424

2525
steps:
26-
- uses: actions/add-to-project@v0.1.0
26+
- uses: actions/add-to-project@v0.6.0
2727
with:
2828
project-url: https://github.com/orgs/python/projects/${{ matrix.project }}
2929
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

.github/workflows/reusable-macos.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
required: false
99
type: boolean
1010
default: false
11+
os-matrix:
12+
required: false
13+
type: string
1114

1215
jobs:
1316
build_macos:
@@ -22,10 +25,7 @@ jobs:
2225
strategy:
2326
fail-fast: false
2427
matrix:
25-
os: [
26-
"macos-14", # M1
27-
"macos-13", # Intel
28-
]
28+
os: ${{fromJson(inputs.os-matrix)}}
2929
runs-on: ${{ matrix.os }}
3030
steps:
3131
- uses: actions/checkout@v4

.github/workflows/reusable-tsan.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
config_hash:
5+
required: true
6+
type: string
7+
options:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build_tsan_reusable:
13+
name: 'Thread sanitizer'
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: 60
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Runner image version
19+
run: echo "IMAGE_VERSION=${ImageVersion}" >> $GITHUB_ENV
20+
- name: Restore config.cache
21+
uses: actions/cache@v4
22+
with:
23+
path: config.cache
24+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
25+
- name: Install Dependencies
26+
run: |
27+
sudo ./.github/workflows/posix-deps-apt.sh
28+
sudo apt install -y clang
29+
# Reduce ASLR to avoid TSAN crashing
30+
sudo sysctl -w vm.mmap_rnd_bits=28
31+
- name: TSAN Option Setup
32+
run: |
33+
echo "TSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/Tools/tsan/supressions.txt" >> $GITHUB_ENV
34+
echo "CC=clang" >> $GITHUB_ENV
35+
echo "CXX=clang++" >> $GITHUB_ENV
36+
- name: Add ccache to PATH
37+
run: |
38+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
39+
- name: Configure ccache action
40+
uses: hendrikmuhs/[email protected]
41+
with:
42+
save: ${{ github.event_name == 'push' }}
43+
max-size: "200M"
44+
- name: Configure CPython
45+
run: ${{ inputs.options }}
46+
- name: Build CPython
47+
run: make -j4
48+
- name: Display build info
49+
run: make pythoninfo
50+
- name: Tests
51+
run: ./python -m test --tsan -j4

.github/workflows/reusable-wasi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-20.04
1313
env:
14-
WASMTIME_VERSION: 18.0.2
15-
WASI_SDK_VERSION: 20
14+
WASMTIME_VERSION: 18.0.3
15+
WASI_SDK_VERSION: 21
1616
WASI_SDK_PATH: /opt/wasi-sdk
1717
CROSS_BUILD_PYTHON: cross-build/build
1818
CROSS_BUILD_WASI: cross-build/wasm32-wasi

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Mark stale pull requests
22

33
on:
44
schedule:
5-
- cron: "0 0 * * *"
5+
- cron: "0 */6 * * *"
66

77
permissions:
88
pull-requests: write

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ Tools/unicode/data/
142142
/profile-clean-stamp
143143
/profile-run-stamp
144144
/profile-bolt-stamp
145-
/Python/deepfreeze/*.c
146145
/pybuilddir.txt
147146
/pyconfig.h
148147
/python-config

Doc/c-api/code.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ bound into a function.
3434
3535
Return the number of free variables in a code object.
3636
37-
.. c:function:: int PyCode_GetFirstFree(PyCodeObject *co)
37+
.. c:function:: int PyUnstable_Code_GetFirstFree(PyCodeObject *co)
3838
3939
Return the position of the first free variable in a code object.
4040
41+
.. versionchanged:: 3.13
42+
43+
Renamed from ``PyCode_GetFirstFree`` as part of :ref:`unstable-c-api`.
44+
The old name is deprecated, but will remain available until the
45+
signature changes again.
46+
4147
.. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
4248
4349
Return a new code object. If you need a dummy code object to create a frame,

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
450450
a “fast path” for small integers. For compact values use
451451
:c:func:`PyUnstable_Long_CompactValue`; for others fall back to a
452452
:c:func:`PyLong_As* <PyLong_AsSize_t>` function or
453-
:c:func:`calling <PyObject_CallMethod>` :meth:`int.to_bytes`.
453+
:c:func:`PyLong_AsNativeBytes`.
454454
455455
The speedup is expected to be negligible for most users.
456456

Doc/c-api/type.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ Type Objects
185185
186186
.. versionadded:: 3.11
187187
188+
.. c:function:: PyObject* PyType_GetFullyQualifiedName(PyTypeObject *type)
189+
190+
Return the type's fully qualified name. Equivalent to
191+
``f"{type.__module__}.{type.__qualname__}"``, or ``type.__qualname__`` if
192+
``type.__module__`` is not a string or is equal to ``"builtins"``.
193+
194+
.. versionadded:: 3.13
195+
196+
.. c:function:: PyObject* PyType_GetModuleName(PyTypeObject *type)
197+
198+
Return the type's module name. Equivalent to getting the ``type.__module__``
199+
attribute.
200+
201+
.. versionadded:: 3.13
202+
188203
.. c:function:: void* PyType_GetSlot(PyTypeObject *type, int slot)
189204
190205
Return the function pointer stored in the given slot. If the

Doc/c-api/unicode.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,26 @@ APIs:
518518
- :c:expr:`PyObject*`
519519
- The result of calling :c:func:`PyObject_Repr`.
520520
521+
* - ``T``
522+
- :c:expr:`PyObject*`
523+
- Get the fully qualified name of an object type;
524+
call :c:func:`PyType_GetFullyQualifiedName`.
525+
526+
* - ``T#``
527+
- :c:expr:`PyObject*`
528+
- Similar to ``T`` format, but use a colon (``:``) as separator between
529+
the module name and the qualified name.
530+
531+
* - ``N``
532+
- :c:expr:`PyTypeObject*`
533+
- Get the fully qualified name of a type;
534+
call :c:func:`PyType_GetFullyQualifiedName`.
535+
536+
* - ``N#``
537+
- :c:expr:`PyTypeObject*`
538+
- Similar to ``N`` format, but use a colon (``:``) as separator between
539+
the module name and the qualified name.
540+
521541
.. note::
522542
The width formatter unit is number of characters rather than bytes.
523543
The precision formatter unit is number of bytes or :c:type:`wchar_t`
@@ -553,6 +573,9 @@ APIs:
553573
In previous versions it caused all the rest of the format string to be
554574
copied as-is to the result string, and any extra arguments discarded.
555575
576+
.. versionchanged:: 3.13
577+
Support for ``%T``, ``%T#``, ``%N`` and ``%N#`` formats added.
578+
556579
557580
.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
558581

Doc/data/stable_abi.dat

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/design.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ is evaluated in all cases.
259259
Why isn't there a switch or case statement in Python?
260260
-----------------------------------------------------
261261

262-
You can do this easily enough with a sequence of ``if... elif... elif... else``.
263-
For literal values, or constants within a namespace, you can also use a
264-
``match ... case`` statement.
262+
In general, structured switch statements execute one block of code
263+
when an expression has a particular value or set of values.
264+
Since Python 3.10 one can easily match literal values, or constants
265+
within a namespace, with a ``match ... case`` statement.
266+
An older alternative is a sequence of ``if... elif... elif... else``.
265267

266268
For cases where you need to choose from a very large number of possibilities,
267269
you can create a dictionary mapping case values to functions to call. For
@@ -290,6 +292,9 @@ It's suggested that you use a prefix for the method names, such as ``visit_`` in
290292
this example. Without such a prefix, if values are coming from an untrusted
291293
source, an attacker would be able to call any method on your object.
292294

295+
Imitating switch with fallthrough, as with C's switch-case-default,
296+
is possible, much harder, and less needed.
297+
293298

294299
Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?
295300
--------------------------------------------------------------------------------------------------------

Doc/faq/extending.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ to learn Python's C API.
5050
If you need to interface to some C or C++ library for which no Python extension
5151
currently exists, you can try wrapping the library's data types and functions
5252
with a tool such as `SWIG <https://www.swig.org>`_. `SIP
53-
<https://riverbankcomputing.com/software/sip/intro>`__, `CXX
53+
<https://github.com/Python-SIP/sip>`__, `CXX
5454
<https://cxx.sourceforge.net/>`_ `Boost
5555
<https://www.boost.org/libs/python/doc/index.html>`_, or `Weave
5656
<https://github.com/scipy/weave>`_ are also

Doc/glossary.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,11 @@ Glossary
841841
Some named tuples are built-in types (such as the above examples).
842842
Alternatively, a named tuple can be created from a regular class
843843
definition that inherits from :class:`tuple` and that defines named
844-
fields. Such a class can be written by hand or it can be created with
845-
the factory function :func:`collections.namedtuple`. The latter
846-
technique also adds some extra methods that may not be found in
847-
hand-written or built-in named tuples.
844+
fields. Such a class can be written by hand, or it can be created by
845+
inheriting :class:`typing.NamedTuple`, or with the factory function
846+
:func:`collections.namedtuple`. The latter techniques also add some
847+
extra methods that may not be found in hand-written or built-in named
848+
tuples.
848849

849850
namespace
850851
The place where a variable is stored. Namespaces are implemented as

0 commit comments

Comments
 (0)