Skip to content

Commit 7b331b4

Browse files
authored
Merge branch 'main' into pass-kwargs-to-task-factory
2 parents 9c91cfa + 6c52ada commit 7b331b4

36 files changed

+586
-129
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/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/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

Doc/library/turtle.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,31 @@ useful when working with learners for whom typing is not a skill.
213213
use turtle graphics with a learner.
214214

215215

216+
Automatically begin and end filling
217+
-----------------------------------
218+
219+
Starting with Python 3.14, you can use the :func:`fill` :term:`context manager`
220+
instead of :func:`begin_fill` and :func:`end_fill` to automatically begin and
221+
end fill. Here is an example::
222+
223+
with fill():
224+
for i in range(4):
225+
forward(100)
226+
right(90)
227+
228+
forward(200)
229+
230+
The code above is equivalent to::
231+
232+
begin_fill()
233+
for i in range(4):
234+
forward(100)
235+
right(90)
236+
end_fill()
237+
238+
forward(200)
239+
240+
216241
Use the ``turtle`` module namespace
217242
-----------------------------------
218243

@@ -351,6 +376,7 @@ Pen control
351376
352377
Filling
353378
| :func:`filling`
379+
| :func:`fill`
354380
| :func:`begin_fill`
355381
| :func:`end_fill`
356382
@@ -381,6 +407,7 @@ Using events
381407
| :func:`ondrag`
382408
383409
Special Turtle methods
410+
| :func:`poly`
384411
| :func:`begin_poly`
385412
| :func:`end_poly`
386413
| :func:`get_poly`
@@ -403,6 +430,7 @@ Window control
403430
| :func:`setworldcoordinates`
404431
405432
Animation control
433+
| :func:`no_animation`
406434
| :func:`delay`
407435
| :func:`tracer`
408436
| :func:`update`
@@ -1275,6 +1303,29 @@ Filling
12751303
... else:
12761304
... turtle.pensize(3)
12771305

1306+
.. function:: fill()
1307+
1308+
Fill the shape drawn in the ``with turtle.fill():`` block.
1309+
1310+
.. doctest::
1311+
:skipif: _tkinter is None
1312+
1313+
>>> turtle.color("black", "red")
1314+
>>> with turtle.fill():
1315+
... turtle.circle(80)
1316+
1317+
Using :func:`!fill` is equivalent to adding the :func:`begin_fill` before the
1318+
fill-block and :func:`end_fill` after the fill-block:
1319+
1320+
.. doctest::
1321+
:skipif: _tkinter is None
1322+
1323+
>>> turtle.color("black", "red")
1324+
>>> turtle.begin_fill()
1325+
>>> turtle.circle(80)
1326+
>>> turtle.end_fill()
1327+
1328+
.. versionadded:: next
12781329

12791330

12801331
.. function:: begin_fill()
@@ -1648,6 +1699,23 @@ Using events
16481699
Special Turtle methods
16491700
----------------------
16501701

1702+
1703+
.. function:: poly()
1704+
1705+
Record the vertices of a polygon drawn in the ``with turtle.poly():`` block.
1706+
The first and last vertices will be connected.
1707+
1708+
.. doctest::
1709+
:skipif: _tkinter is None
1710+
1711+
>>> with turtle.poly():
1712+
... turtle.forward(100)
1713+
... turtle.right(60)
1714+
... turtle.forward(100)
1715+
1716+
.. versionadded:: next
1717+
1718+
16511719
.. function:: begin_poly()
16521720

16531721
Start recording the vertices of a polygon. Current turtle position is first
@@ -1926,6 +1994,23 @@ Window control
19261994
Animation control
19271995
-----------------
19281996

1997+
.. function:: no_animation()
1998+
1999+
Temporarily disable turtle animation. The code written inside the
2000+
``no_animation`` block will not be animated;
2001+
once the code block is exited, the drawing will appear.
2002+
2003+
.. doctest::
2004+
:skipif: _tkinter is None
2005+
2006+
>>> with screen.no_animation():
2007+
... for dist in range(2, 400, 2):
2008+
... fd(dist)
2009+
... rt(90)
2010+
2011+
.. versionadded:: next
2012+
2013+
19292014
.. function:: delay(delay=None)
19302015

19312016
:param delay: positive integer

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,14 @@ tkinter
660660
(Contributed by Zhikang Yan in :gh:`126899`.)
661661

662662

663+
turtle
664+
------
665+
666+
* Add context managers for :func:`turtle.fill`, :func:`turtle.poly`
667+
and :func:`turtle.no_animation`.
668+
(Contributed by Marie Roald and Yngve Mardal Moe in :gh:`126350`.)
669+
670+
663671
unicodedata
664672
-----------
665673

0 commit comments

Comments
 (0)