Skip to content

Commit 5e1ba4a

Browse files
authored
Merge branch 'main' into doc-ob-mutex-warning
2 parents 72f2d44 + 80ba4e1 commit 5e1ba4a

Some content is hidden

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

59 files changed

+806
-354
lines changed

.github/workflows/tail-call.yml

Lines changed: 72 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
name: Tail calling interpreter
22
on:
33
pull_request:
4-
paths:
4+
paths: &paths
55
- '.github/workflows/tail-call.yml'
66
- 'Python/bytecodes.c'
77
- 'Python/ceval.c'
88
- 'Python/ceval_macros.h'
99
- 'Python/generated_cases.c.h'
1010
push:
11-
paths:
12-
- '.github/workflows/tail-call.yml'
13-
- 'Python/bytecodes.c'
14-
- 'Python/ceval.c'
15-
- 'Python/ceval_macros.h'
16-
- 'Python/generated_cases.c.h'
11+
paths: *paths
1712
workflow_dispatch:
1813

1914
permissions:
@@ -25,117 +20,109 @@ concurrency:
2520

2621
env:
2722
FORCE_COLOR: 1
23+
LLVM_VERSION: 21
2824

2925
jobs:
30-
tail-call:
26+
windows:
3127
name: ${{ matrix.target }}
3228
runs-on: ${{ matrix.runner }}
33-
timeout-minutes: 90
29+
timeout-minutes: 60
3430
strategy:
3531
fail-fast: false
3632
matrix:
37-
target:
38-
# Un-comment as we add support for more platforms for tail-calling interpreters.
39-
# - i686-pc-windows-msvc/msvc
40-
- x86_64-pc-windows-msvc/msvc
41-
- free-threading-msvc
42-
# - aarch64-pc-windows-msvc/msvc
43-
- x86_64-apple-darwin/clang
44-
- aarch64-apple-darwin/clang
45-
- x86_64-unknown-linux-gnu/gcc
46-
- aarch64-unknown-linux-gnu/gcc
47-
- free-threading
48-
llvm:
49-
- 20
5033
include:
51-
# - target: i686-pc-windows-msvc/msvc
52-
# architecture: Win32
53-
# runner: windows-2022
5434
- target: x86_64-pc-windows-msvc/msvc
5535
architecture: x64
5636
runner: windows-2025-vs2026
57-
- target: free-threading-msvc
37+
build_flags: ""
38+
run_tests: true
39+
- target: x86_64-pc-windows-msvc/msvc-free-threading
5840
architecture: x64
5941
runner: windows-2025-vs2026
60-
# - target: aarch64-pc-windows-msvc/msvc
61-
# architecture: ARM64
62-
# runner: windows-2022
63-
- target: x86_64-apple-darwin/clang
64-
architecture: x86_64
65-
runner: macos-15-intel
66-
- target: aarch64-apple-darwin/clang
67-
architecture: aarch64
68-
runner: macos-14
69-
- target: x86_64-unknown-linux-gnu/gcc
70-
architecture: x86_64
71-
runner: ubuntu-24.04
72-
- target: aarch64-unknown-linux-gnu/gcc
73-
architecture: aarch64
74-
runner: ubuntu-24.04-arm
75-
- target: free-threading
76-
architecture: x86_64
77-
runner: ubuntu-24.04
42+
build_flags: --disable-gil
43+
run_tests: false
7844
steps:
7945
- uses: actions/checkout@v6
8046
with:
8147
persist-credentials: false
8248
- uses: actions/setup-python@v6
8349
with:
8450
python-version: '3.11'
85-
86-
- name: Native Windows MSVC (release)
87-
if: runner.os == 'Windows' && matrix.architecture != 'ARM64' && matrix.target != 'free-threading-msvc'
51+
- name: Build
8852
shell: pwsh
8953
run: |
9054
$env:PlatformToolset = "v145"
91-
./PCbuild/build.bat --tail-call-interp -c Release -p ${{ matrix.architecture }}
92-
./PCbuild/rt.bat -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
93-
94-
# No tests:
95-
- name: Native Windows MSVC with free-threading (release)
96-
if: matrix.target == 'free-threading-msvc'
97-
shell: pwsh
98-
run: |
99-
$env:PlatformToolset = "v145"
100-
./PCbuild/build.bat --tail-call-interp --disable-gil -c Release -p ${{ matrix.architecture }}
101-
102-
# No tests (yet):
103-
- name: Emulated Windows Clang (release)
104-
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
55+
./PCbuild/build.bat --tail-call-interp ${{ matrix.build_flags }} -c Release -p ${{ matrix.architecture }}
56+
- name: Test
57+
if: matrix.run_tests
10558
shell: pwsh
10659
run: |
107-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
108-
$env:PlatformToolset = "clangcl"
109-
$env:LLVMToolsVersion = "${{ matrix.llvm }}.1.0"
110-
$env:LLVMInstallDir = "C:\Program Files\LLVM"
111-
./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }}
60+
./PCbuild/rt.bat -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
11261
113-
- name: Native macOS (release)
114-
if: runner.os == 'macOS'
62+
macos:
63+
name: ${{ matrix.target }}
64+
runs-on: ${{ matrix.runner }}
65+
timeout-minutes: 60
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
include:
70+
- target: x86_64-apple-darwin/clang
71+
runner: macos-15-intel
72+
- target: aarch64-apple-darwin/clang
73+
runner: macos-14
74+
steps:
75+
- uses: actions/checkout@v6
76+
with:
77+
persist-credentials: false
78+
- uses: actions/setup-python@v6
79+
with:
80+
python-version: '3.11'
81+
- name: Install dependencies
11582
run: |
11683
brew update
117-
brew install llvm@${{ matrix.llvm }}
84+
brew install llvm@${{ env.LLVM_VERSION }}
85+
- name: Build
86+
run: |
11887
export SDKROOT="$(xcrun --show-sdk-path)"
119-
export PATH="/usr/local/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
120-
export PATH="/opt/homebrew/opt/llvm@${{ matrix.llvm }}/bin:$PATH"
121-
CC=clang-20 ./configure --with-tail-call-interp
88+
export PATH="/usr/local/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH"
89+
export PATH="/opt/homebrew/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH"
90+
CC=clang-${{ env.LLVM_VERSION }} ./configure --with-tail-call-interp
12291
make all --jobs 4
92+
- name: Test
93+
run: |
12394
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
12495
125-
- name: Native Linux (debug)
126-
if: runner.os == 'Linux' && matrix.target != 'free-threading'
96+
linux:
97+
name: ${{ matrix.target }}
98+
runs-on: ${{ matrix.runner }}
99+
timeout-minutes: 60
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
include:
104+
- target: x86_64-unknown-linux-gnu/gcc
105+
runner: ubuntu-24.04
106+
configure_flags: --with-pydebug
107+
- target: x86_64-unknown-linux-gnu/gcc-free-threading
108+
runner: ubuntu-24.04
109+
configure_flags: --disable-gil
110+
- target: aarch64-unknown-linux-gnu/gcc
111+
runner: ubuntu-24.04-arm
112+
configure_flags: --with-pydebug
113+
steps:
114+
- uses: actions/checkout@v6
115+
with:
116+
persist-credentials: false
117+
- uses: actions/setup-python@v6
118+
with:
119+
python-version: '3.11'
120+
- name: Build
127121
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-
CC=clang-20 ./configure --with-tail-call-interp --with-pydebug
122+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ env.LLVM_VERSION }}
123+
export PATH="$(llvm-config-${{ env.LLVM_VERSION }} --bindir):$PATH"
124+
CC=clang-${{ env.LLVM_VERSION }} ./configure --with-tail-call-interp ${{ matrix.configure_flags }}
131125
make all --jobs 4
132-
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
133-
134-
- name: Native Linux with free-threading (release)
135-
if: matrix.target == 'free-threading'
126+
- name: Test
136127
run: |
137-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
138-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
139-
CC=clang-20 ./configure --with-tail-call-interp --disable-gil
140-
make all --jobs 4
141128
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

Doc/c-api/module.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,11 @@ remove it.
725725
726726
An array of additional slots, terminated by a ``{0, NULL}`` entry.
727727
728-
This array may not contain slots corresponding to :c:type:`PyModuleDef`
729-
members.
730-
For example, you cannot use :c:macro:`Py_mod_name` in :c:member:`!m_slots`;
731-
the module name must be given as :c:member:`PyModuleDef.m_name`.
728+
If the array contains slots corresponding to :c:type:`PyModuleDef`
729+
members, the values must match.
730+
For example, if you use :c:macro:`Py_mod_name` in :c:member:`!m_slots`,
731+
:c:member:`PyModuleDef.m_name` must be set to the same pointer
732+
(not just an equal string).
732733
733734
.. versionchanged:: 3.5
734735

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ although there is currently no date scheduled for their removal.
3535
* Support for ``__complex__()`` method returning a strict subclass of
3636
:class:`complex`: these methods will be required to return an instance of
3737
:class:`complex`.
38-
* Delegation of ``int()`` to ``__trunc__()`` method.
3938
* Passing a complex number as the *real* or *imag* argument in the
4039
:func:`complex` constructor is now deprecated; it should only be passed
4140
as a single positional argument.

Doc/library/datetime.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ requires, and these work on all supported platforms.
25402540
| ``%e`` | The day of the month as a | ␣1, ␣2, ..., 31 | |
25412541
| | space-padded decimal number. | | |
25422542
+-----------+--------------------------------+------------------------+-------+
2543-
| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | \(0) |
2543+
| ``%F`` | Equivalent to ``%Y-%m-%d``, | 2025-10-11, | |
25442544
| | the ISO 8601 format. | 1001-12-30 | |
25452545
+-----------+--------------------------------+------------------------+-------+
25462546
| ``%g`` | Last 2 digits of ISO 8601 year | 00, 01, ..., 99 | \(0) |
@@ -2673,10 +2673,10 @@ differences between platforms in handling of unsupported format specifiers.
26732673
``%G``, ``%u`` and ``%V`` were added.
26742674

26752675
.. versionadded:: 3.12
2676-
``%:z`` was added for :meth:`~.datetime.strftime`
2676+
``%:z`` was added for :meth:`~.datetime.strftime`.
26772677

26782678
.. versionadded:: 3.15
2679-
``%:z`` was added for :meth:`~.datetime.strptime`
2679+
``%:z`` and ``%F`` were added for :meth:`~.datetime.strptime`.
26802680

26812681
Technical Detail
26822682
^^^^^^^^^^^^^^^^

Doc/library/typing.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,12 @@ types.
25272527

25282528
.. versionadded:: 3.8
25292529

2530+
.. deprecated-removed:: 3.15 3.20
2531+
It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on
2532+
protocol classes that were not explicitly decorated with :func:`!runtime_checkable`
2533+
but that inherit from a runtime-checkable protocol class. This will throw
2534+
a :exc:`TypeError` in Python 3.20.
2535+
25302536
.. decorator:: runtime_checkable
25312537

25322538
Mark a protocol class as a runtime protocol.
@@ -2548,6 +2554,18 @@ types.
25482554
import threading
25492555
assert isinstance(threading.Thread(name='Bob'), Named)
25502556

2557+
Runtime checkability of protocols is not inherited. A subclass of a runtime-checkable protocol
2558+
is only runtime-checkable if it is explicitly marked as such, regardless of class hierarchy::
2559+
2560+
@runtime_checkable
2561+
class Iterable(Protocol):
2562+
def __iter__(self): ...
2563+
2564+
# Without @runtime_checkable, Reversible would no longer be runtime-checkable.
2565+
@runtime_checkable
2566+
class Reversible(Iterable, Protocol):
2567+
def __reversed__(self): ...
2568+
25512569
This decorator raises :exc:`TypeError` when applied to a non-protocol class.
25522570

25532571
.. note::
@@ -2588,6 +2606,11 @@ types.
25882606
protocol. See :ref:`What's new in Python 3.12 <whatsnew-typing-py312>`
25892607
for more details.
25902608

2609+
.. deprecated-removed:: 3.15 3.20
2610+
It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on
2611+
protocol classes that were not explicitly decorated with :func:`!runtime_checkable`
2612+
but that inherit from a runtime-checkable protocol class. This will throw
2613+
a :exc:`TypeError` in Python 3.20.
25912614

25922615
.. class:: TypedDict(dict)
25932616

Include/datetime.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,23 @@ typedef struct {
196196
/* Define global variable for the C API and a macro for setting it. */
197197
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
198198

199-
#define PyDateTime_IMPORT \
200-
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
199+
static inline PyDateTime_CAPI *
200+
_PyDateTime_IMPORT(void) {
201+
PyDateTime_CAPI *val = _Py_atomic_load_ptr(&PyDateTimeAPI);
202+
if (val == NULL) {
203+
PyDateTime_CAPI *capi = (PyDateTime_CAPI *)PyCapsule_Import(
204+
PyDateTime_CAPSULE_NAME, 0);
205+
if (capi != NULL) {
206+
/* if the compare exchange fails then in that case
207+
another thread would have initialized it */
208+
_Py_atomic_compare_exchange_ptr(&PyDateTimeAPI, &val, (void *)capi);
209+
return capi;
210+
}
211+
}
212+
return val;
213+
}
214+
215+
#define PyDateTime_IMPORT _PyDateTime_IMPORT()
201216

202217
/* Macro for access to the UTC singleton */
203218
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC

Lib/_strptime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def __init__(self, locale_time=None):
418418
mapping['W'] = mapping['U'].replace('U', 'W')
419419

420420
base.__init__(mapping)
421+
base.__setitem__('F', self.pattern('%Y-%m-%d'))
421422
base.__setitem__('T', self.pattern('%H:%M:%S'))
422423
base.__setitem__('R', self.pattern('%H:%M'))
423424
base.__setitem__('r', self.pattern(self.locale_time.LC_time_ampm))

Lib/compileall.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
165165
stripdir = os.fspath(stripdir) if stripdir is not None else None
166166
name = os.path.basename(fullname)
167167

168+
# Without a cache_tag, we can only create legacy .pyc files. None of our
169+
# callers seem to expect this, so the best we can do is fail without raising
170+
if not legacy and sys.implementation.cache_tag is None:
171+
if not quiet:
172+
print("No cache tag is available to generate .pyc path for",
173+
repr(fullname))
174+
return False
175+
168176
dfile = None
169177

170178
if ddir is not None:

Lib/ensurepip/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
177177
args += ["--user"]
178178
if verbosity:
179179
args += ["-" + "v" * verbosity]
180+
if sys.implementation.cache_tag is None:
181+
args += ["--no-compile"]
180182

181183
return _run_pip([*args, "pip"], [os.fsdecode(tmp_wheel_path)])
182184

Lib/py_compile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ def main():
194194
else:
195195
filenames = args.filenames
196196
for filename in filenames:
197+
cfilename = (None if sys.implementation.cache_tag
198+
else f"{filename.rpartition('.')[0]}.pyc")
197199
try:
198-
compile(filename, doraise=True)
200+
compile(filename, cfilename, doraise=True)
199201
except PyCompileError as error:
200202
if args.quiet:
201203
parser.exit(1)

0 commit comments

Comments
 (0)