Skip to content

Commit e7bc9bc

Browse files
authored
Merge branch 'main' into remove-arg
2 parents 26f7a0d + 6c52ada commit e7bc9bc

File tree

123 files changed

+3373
-1468
lines changed

Some content is hidden

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

123 files changed

+3373
-1468
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ jobs:
231231
name: >-
232232
Ubuntu
233233
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
234+
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
234235
needs: check_source
235236
if: needs.check_source.outputs.run_tests == 'true'
236237
strategy:
237238
matrix:
239+
bolt:
240+
- false
241+
- true
238242
free-threading:
239243
- false
240244
- true
@@ -246,9 +250,16 @@ jobs:
246250
exclude:
247251
- os: ubuntu-24.04-aarch64
248252
is-fork: true
253+
# Do not test BOLT with free-threading, to conserve resources
254+
- bolt: true
255+
free-threading: true
256+
# BOLT currently crashes during instrumentation on aarch64
257+
- os: ubuntu-24.04-aarch64
258+
bolt: true
249259
uses: ./.github/workflows/reusable-ubuntu.yml
250260
with:
251261
config_hash: ${{ needs.check_source.outputs.config_hash }}
262+
bolt-optimizations: ${{ matrix.bolt }}
252263
free-threading: ${{ matrix.free-threading }}
253264
os: ${{ matrix.os }}
254265

.github/workflows/reusable-ubuntu.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
config_hash:
77
required: true
88
type: string
9+
bolt-optimizations:
10+
description: Whether to enable BOLT optimizations
11+
required: false
12+
type: boolean
13+
default: false
914
free-threading:
1015
description: Whether to use free-threaded mode
1116
required: false
@@ -34,6 +39,12 @@ jobs:
3439
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
3540
- name: Install dependencies
3641
run: sudo ./.github/workflows/posix-deps-apt.sh
42+
- name: Install Clang and BOLT
43+
if: ${{ fromJSON(inputs.bolt-optimizations) }}
44+
run: |
45+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19
46+
sudo apt-get install bolt-19
47+
echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV
3748
- name: Configure OpenSSL env vars
3849
run: |
3950
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
@@ -73,14 +84,18 @@ jobs:
7384
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
7485
- name: Configure CPython out-of-tree
7586
working-directory: ${{ env.CPYTHON_BUILDDIR }}
87+
# `test_unpickle_module_race` writes to the source directory, which is
88+
# read-only during builds — so we exclude it from profiling with BOLT.
7689
run: >-
90+
PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race'
7791
../cpython-ro-srcdir/configure
7892
--config-cache
7993
--with-pydebug
8094
--enable-slower-safety
8195
--enable-safety
8296
--with-openssl="$OPENSSL_DIR"
8397
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
98+
${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }}
8499
- name: Build CPython out-of-tree
85100
if: ${{ inputs.free-threading }}
86101
working-directory: ${{ env.CPYTHON_BUILDDIR }}

.pre-commit-config.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.2
3+
rev: v0.9.1
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/
@@ -29,12 +29,10 @@ repos:
2929
- id: black
3030
name: Run Black on Tools/build/check_warnings.py
3131
files: ^Tools/build/check_warnings.py
32-
language_version: python3.12
3332
args: [--line-length=79]
3433
- id: black
3534
name: Run Black on Tools/jit/
3635
files: ^Tools/jit/
37-
language_version: python3.12
3836

3937
- repo: https://github.com/pre-commit/pre-commit-hooks
4038
rev: v5.0.0
@@ -51,19 +49,19 @@ repos:
5149
types_or: [c, inc, python, rst]
5250

5351
- repo: https://github.com/python-jsonschema/check-jsonschema
54-
rev: 0.30.0
52+
rev: 0.31.0
5553
hooks:
5654
- id: check-dependabot
5755
- id: check-github-workflows
5856
- id: check-readthedocs
5957

6058
- repo: https://github.com/rhysd/actionlint
61-
rev: v1.7.4
59+
rev: v1.7.6
6260
hooks:
6361
- id: actionlint
6462

6563
- repo: https://github.com/woodruffw/zizmor-pre-commit
66-
rev: v0.8.0
64+
rev: v1.1.1
6765
hooks:
6866
- id: zizmor
6967

Doc/faq/programming.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,28 +1906,30 @@ In the standard library code, you will see several common patterns for
19061906
correctly using identity tests:
19071907

19081908
1) As recommended by :pep:`8`, an identity test is the preferred way to check
1909-
for ``None``. This reads like plain English in code and avoids confusion with
1910-
other objects that may have boolean values that evaluate to false.
1909+
for ``None``. This reads like plain English in code and avoids confusion
1910+
with other objects that may have boolean values that evaluate to false.
19111911

19121912
2) Detecting optional arguments can be tricky when ``None`` is a valid input
1913-
value. In those situations, you can create a singleton sentinel object
1914-
guaranteed to be distinct from other objects. For example, here is how
1915-
to implement a method that behaves like :meth:`dict.pop`::
1913+
value. In those situations, you can create a singleton sentinel object
1914+
guaranteed to be distinct from other objects. For example, here is how
1915+
to implement a method that behaves like :meth:`dict.pop`:
19161916

1917-
_sentinel = object()
1917+
.. code-block:: python
19181918
1919-
def pop(self, key, default=_sentinel):
1920-
if key in self:
1921-
value = self[key]
1922-
del self[key]
1923-
return value
1924-
if default is _sentinel:
1925-
raise KeyError(key)
1926-
return default
1919+
_sentinel = object()
1920+
1921+
def pop(self, key, default=_sentinel):
1922+
if key in self:
1923+
value = self[key]
1924+
del self[key]
1925+
return value
1926+
if default is _sentinel:
1927+
raise KeyError(key)
1928+
return default
19271929
19281930
3) Container implementations sometimes need to augment equality tests with
1929-
identity tests. This prevents the code from being confused by objects such as
1930-
``float('NaN')`` that are not equal to themselves.
1931+
identity tests. This prevents the code from being confused by objects
1932+
such as ``float('NaN')`` that are not equal to themselves.
19311933

19321934
For example, here is the implementation of
19331935
:meth:`!collections.abc.Sequence.__contains__`::

Doc/glossary.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Glossary
115115
:keyword:`yield` expression.
116116

117117
Each :keyword:`yield` temporarily suspends processing, remembering the
118-
location execution state (including local variables and pending
118+
execution state (including local variables and pending
119119
try-statements). When the *asynchronous generator iterator* effectively
120120
resumes with another awaitable returned by :meth:`~object.__anext__`, it
121121
picks up where it left off. See :pep:`492` and :pep:`525`.
@@ -564,7 +564,7 @@ Glossary
564564
An object created by a :term:`generator` function.
565565

566566
Each :keyword:`yield` temporarily suspends processing, remembering the
567-
location execution state (including local variables and pending
567+
execution state (including local variables and pending
568568
try-statements). When the *generator iterator* resumes, it picks up where
569569
it left off (in contrast to functions which start fresh on every
570570
invocation).

Doc/library/email.contentmanager.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ Currently the email package provides only one concrete content manager,
157157
:exc:`ValueError`.
158158

159159
* For ``str`` objects, if *cte* is not set use heuristics to
160-
determine the most compact encoding.
160+
determine the most compact encoding. Prior to encoding,
161+
:meth:`str.splitlines` is used to normalize all line boundaries,
162+
ensuring that each line of the payload is terminated by the
163+
current policy's :data:`~email.policy.Policy.linesep` property
164+
(even if the original string did not end with one).
165+
* For ``bytes`` objects, *cte* is taken to be base64 if not set,
166+
and the aforementioned newline translation is not performed.
161167
* For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise
162168
an error if a *cte* of ``quoted-printable`` or ``base64`` is
163169
requested for *subtype* ``rfc822``, and for any *cte* other than

Doc/library/importlib.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ ABC hierarchy::
380380

381381
.. class:: ResourceLoader
382382

383+
*Superseded by TraversableResources*
384+
383385
An abstract base class for a :term:`loader` which implements the optional
384386
:pep:`302` protocol for loading arbitrary resources from the storage
385387
back-end.
386388

387389
.. deprecated:: 3.7
388390
This ABC is deprecated in favour of supporting resource loading
389-
through :class:`importlib.resources.abc.ResourceReader`.
391+
through :class:`importlib.resources.abc.TraversableResources`.
390392

391393
.. abstractmethod:: get_data(path)
392394

Doc/library/os.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5411,6 +5411,8 @@ information, consult your Unix manpages.
54115411
The following scheduling policies are exposed if they are supported by the
54125412
operating system.
54135413

5414+
.. _os-scheduling-policy:
5415+
54145416
.. data:: SCHED_OTHER
54155417

54165418
The default scheduling policy.
@@ -5514,7 +5516,7 @@ operating system.
55145516

55155517
.. function:: sched_yield()
55165518

5517-
Voluntarily relinquish the CPU.
5519+
Voluntarily relinquish the CPU. See :manpage:`sched_yield(2)` for details.
55185520

55195521

55205522
.. function:: sched_setaffinity(pid, mask, /)

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This module provides access to some variables used or maintained by the
1010
interpreter and to functions that interact strongly with the interpreter. It is
11-
always available.
11+
always available. Unless explicitly noted otherwise, all variables are read-only.
1212

1313

1414
.. data:: abiflags

Doc/library/time.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ Functions
385385
The suspension time may be longer than requested by an arbitrary amount,
386386
because of the scheduling of other activity in the system.
387387

388+
.. rubric:: Windows implementation
389+
388390
On Windows, if *secs* is zero, the thread relinquishes the remainder of its
389391
time slice to any other thread that is ready to run. If there are no other
390392
threads ready to run, the function returns immediately, and the thread
@@ -393,12 +395,19 @@ Functions
393395
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers>`_
394396
which provides resolution of 100 nanoseconds. If *secs* is zero, ``Sleep(0)`` is used.
395397

396-
Unix implementation:
398+
.. rubric:: Unix implementation
397399

398400
* Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);
399401
* Or use ``nanosleep()`` if available (resolution: 1 nanosecond);
400402
* Or use ``select()`` (resolution: 1 microsecond).
401403

404+
.. note::
405+
406+
To emulate a "no-op", use :keyword:`pass` instead of ``time.sleep(0)``.
407+
408+
To voluntarily relinquish the CPU, specify a real-time :ref:`scheduling
409+
policy <os-scheduling-policy>` and use :func:`os.sched_yield` instead.
410+
402411
.. audit-event:: time.sleep secs
403412

404413
.. versionchanged:: 3.5

0 commit comments

Comments
 (0)