Skip to content

Commit 12b616b

Browse files
committed
Merge branch 'main' into object_getdict
2 parents ba6ebef + ded59f7 commit 12b616b

File tree

95 files changed

+1365
-610
lines changed

Some content is hidden

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

95 files changed

+1365
-610
lines changed

.github/workflows/reusable-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
4444
- name: Install Homebrew dependencies
4545
run: |
46-
brew install pkg-config [email protected] xz gdbm tcl-tk@8 make
46+
brew install pkg-config [email protected] xz gdbm tcl-tk@9 make
4747
# Because alternate versions are not symlinked into place by default:
48-
brew link --overwrite tcl-tk@8
48+
brew link --overwrite tcl-tk@9
4949
- name: Configure CPython
5050
run: |
5151
MACOSX_DEPLOYMENT_TARGET=10.15 \

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ Object Protocol
630630
631631
Clear the managed dictionary of *obj*.
632632
633-
This function must only be called in a traverse function of the type which
633+
This function must only be called in a clear function of the type which
634634
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
635635
636636
.. versionadded:: 3.13

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
17041704
:c:func:`Py_CLEAR` macro performs the operations in a safe order.
17051705

17061706
If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
1707-
:c:member:`~PyTypeObject.tp_flags` field, the traverse function must call
1707+
:c:member:`~PyTypeObject.tp_flags` field, the clear function must call
17081708
:c:func:`PyObject_ClearManagedDict` like this::
17091709

17101710
PyObject_ClearManagedDict((PyObject*)self);

Doc/howto/a-conceptual-overview-of-asyncio.rst

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ model of how :mod:`asyncio` fundamentally works, helping you understand the
99
how and why behind the recommended patterns.
1010

1111
You might be curious about some key :mod:`!asyncio` concepts.
12-
You'll be comfortably able to answer these questions by the end of this
13-
article:
12+
By the end of this article, you'll be able to comfortably answer these questions:
1413

1514
- What's happening behind the scenes when an object is awaited?
1615
- How does :mod:`!asyncio` differentiate between a task which doesn't need
17-
CPU-time (such as a network request or file read) as opposed to a task that
16+
CPU time (such as a network request or file read) as opposed to a task that
1817
does (such as computing n-factorial)?
1918
- How to write an asynchronous variant of an operation, such as
2019
an async sleep or database request.
@@ -35,7 +34,7 @@ A conceptual overview part 1: the high-level
3534
--------------------------------------------
3635

3736
In part 1, we'll cover the main, high-level building blocks of :mod:`!asyncio`:
38-
the event loop, coroutine functions, coroutine objects, tasks and ``await``.
37+
the event loop, coroutine functions, coroutine objects, tasks, and ``await``.
3938

4039
==========
4140
Event Loop
@@ -56,7 +55,7 @@ Once it pauses or completes, it returns control to the event loop.
5655
The event loop will then select another job from its pool and invoke it.
5756
You can *roughly* think of the collection of jobs as a queue: jobs are added and
5857
then processed one at a time, generally (but not always) in order.
59-
This process repeats indefinitely with the event loop cycling endlessly
58+
This process repeats indefinitely, with the event loop cycling endlessly
6059
onwards.
6160
If there are no more jobs pending execution, the event loop is smart enough to
6261
rest and avoid needlessly wasting CPU cycles, and will come back when there's
@@ -276,7 +275,7 @@ in this case, a call to resume ``plant_a_tree()``.
276275

277276
Generally speaking, when the awaited task finishes (``dig_the_hole_task``),
278277
the original task or coroutine (``plant_a_tree()``) is added back to the event
279-
loops to-do list to be resumed.
278+
loop's to-do list to be resumed.
280279

281280
This is a basic, yet reliable mental model.
282281
In practice, the control handoffs are slightly more complex, but not by much.
@@ -310,7 +309,7 @@ Consider this program::
310309
The first statement in the coroutine ``main()`` creates ``task_b`` and schedules
311310
it for execution via the event loop.
312311
Then, ``coro_a()`` is repeatedly awaited. Control never cedes to the
313-
event loop which is why we see the output of all three ``coro_a()``
312+
event loop, which is why we see the output of all three ``coro_a()``
314313
invocations before ``coro_b()``'s output:
315314

316315
.. code-block:: none
@@ -338,8 +337,8 @@ This behavior of ``await coroutine`` can trip a lot of people up!
338337
That example highlights how using only ``await coroutine`` could
339338
unintentionally hog control from other tasks and effectively stall the event
340339
loop.
341-
:func:`asyncio.run` can help you detect such occurences via the
342-
``debug=True`` flag which accordingly enables
340+
:func:`asyncio.run` can help you detect such occurrences via the
341+
``debug=True`` flag, which enables
343342
:ref:`debug mode <asyncio-debug-mode>`.
344343
Among other things, it will log any coroutines that monopolize execution for
345344
100ms or longer.
@@ -348,8 +347,8 @@ The design intentionally trades off some conceptual clarity around usage of
348347
``await`` for improved performance.
349348
Each time a task is awaited, control needs to be passed all the way up the
350349
call stack to the event loop.
351-
That might sound minor, but in a large program with many ``await``'s and a deep
352-
callstack that overhead can add up to a meaningful performance drag.
350+
That might sound minor, but in a large program with many ``await`` statements and a deep
351+
call stack, that overhead can add up to a meaningful performance drag.
353352

354353
------------------------------------------------
355354
A conceptual overview part 2: the nuts and bolts
@@ -372,7 +371,7 @@ resume a coroutine.
372371
If the coroutine was paused and is now being resumed, the argument ``arg``
373372
will be sent in as the return value of the ``yield`` statement which originally
374373
paused it.
375-
If the coroutine is being used for the first time (as opposed to being resumed)
374+
If the coroutine is being used for the first time (as opposed to being resumed),
376375
``arg`` must be ``None``.
377376

378377
.. code-block::
@@ -403,14 +402,14 @@ If the coroutine is being used for the first time (as opposed to being resumed)
403402
returned_value = e.value
404403
print(f"Coroutine main() finished and provided value: {returned_value}.")
405404
406-
:ref:`yield <yieldexpr>`, like usual, pauses execution and returns control
405+
:ref:`yield <yieldexpr>`, as usual, pauses execution and returns control
407406
to the caller.
408407
In the example above, the ``yield``, on line 3, is called by
409408
``... = await rock`` on line 11.
410409
More broadly speaking, ``await`` calls the :meth:`~object.__await__` method of
411410
the given object.
412411
``await`` also does one more very special thing: it propagates (or "passes
413-
along") any ``yield``\ s it receives up the call-chain.
412+
along") any ``yield``\ s it receives up the call chain.
414413
In this case, that's back to ``... = coroutine.send(None)`` on line 16.
415414

416415
The coroutine is resumed via the ``coroutine.send(42)`` call on line 21.
@@ -462,12 +461,12 @@ computation's status and result.
462461
The term is a nod to the idea of something still to come or not yet happened,
463462
and the object is a way to keep an eye on that something.
464463

465-
A future has a few important attributes. One is its state which can be either
466-
"pending", "cancelled" or "done".
464+
A future has a few important attributes. One is its state, which can be either
465+
"pending", "cancelled", or "done".
467466
Another is its result, which is set when the state transitions to done.
468467
Unlike a coroutine, a future does not represent the actual computation to be
469468
done; instead, it represents the status and result of that computation, kind of
470-
like a status light (red, yellow or green) or indicator.
469+
like a status light (red, yellow, or green) or indicator.
471470

472471
:class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain
473472
these various capabilities.
@@ -490,8 +489,8 @@ We'll go through an example of how you could leverage a future to create your
490489
own variant of asynchronous sleep (``async_sleep``) which mimics
491490
:func:`asyncio.sleep`.
492491

493-
This snippet registers a few tasks with the event loop and then awaits a
494-
coroutine wrapped in a task: ``async_sleep(3)``.
492+
This snippet registers a few tasks with the event loop and then awaits the task
493+
created by ``asyncio.create_task``, which wraps the ``async_sleep(3)`` coroutine.
495494
We want that task to finish only after three seconds have elapsed, but without
496495
preventing other tasks from running.
497496

@@ -540,8 +539,8 @@ will monitor how much time has elapsed and, accordingly, call
540539
# Block until the future is marked as done.
541540
await future
542541

543-
Below, we'll use a rather bare object, ``YieldToEventLoop()``, to ``yield``
544-
from ``__await__`` in order to cede control to the event loop.
542+
Below, we use a rather bare ``YieldToEventLoop()`` object to ``yield``
543+
from its ``__await__`` method, ceding control to the event loop.
545544
This is effectively the same as calling ``asyncio.sleep(0)``, but this approach
546545
offers more clarity, not to mention it's somewhat cheating to use
547546
``asyncio.sleep`` when showcasing how to implement it!
@@ -552,13 +551,13 @@ The ``watcher_task``, which runs the coroutine ``_sleep_watcher(...)``, will
552551
be invoked once per full cycle of the event loop.
553552
On each resumption, it'll check the time and if not enough has elapsed, then
554553
it'll pause once again and hand control back to the event loop.
555-
Eventually, enough time will have elapsed, and ``_sleep_watcher(...)`` will
556-
mark the future as done, and then itself finish too by breaking out of the
554+
Once enough time has elapsed, ``_sleep_watcher(...)``
555+
marks the future as done and completes by exiting its
557556
infinite ``while`` loop.
558557
Given this helper task is only invoked once per cycle of the event loop,
559558
you'd be correct to note that this asynchronous sleep will sleep *at least*
560559
three seconds, rather than exactly three seconds.
561-
Note this is also of true of ``asyncio.sleep``.
560+
Note this is also true of ``asyncio.sleep``.
562561

563562
::
564563

@@ -601,6 +600,6 @@ For reference, you could implement it without futures, like so::
601600
else:
602601
await YieldToEventLoop()
603602

604-
But, that's all for now. Hopefully you're ready to more confidently dive into
603+
But that's all for now. Hopefully you're ready to more confidently dive into
605604
some async programming or check out advanced topics in the
606605
:mod:`rest of the documentation <asyncio>`.

Doc/library/cmath.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Constants
338338
.. data:: nan
339339

340340
A floating-point "not a number" (NaN) value. Equivalent to
341-
``float('nan')``.
341+
``float('nan')``. See also :data:`math.nan`.
342342

343343
.. versionadded:: 3.6
344344

Doc/library/http.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
139139

140140
.. versionchanged:: 3.13
141141
Implemented RFC9110 naming for status constants. Old constant names are preserved for
142-
backwards compatibility.
142+
backwards compatibility: ``413 REQUEST_ENTITY_TOO_LARGE``, ``414 REQUEST_URI_TOO_LONG``,
143+
``416 REQUESTED_RANGE_NOT_SATISFIABLE`` and ``422 UNPROCESSABLE_ENTITY``.
143144

144145
HTTP status category
145146
--------------------

Doc/library/importlib.resources.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ for example, a package and its resources can be imported from a zip file using
7272

7373
.. versionadded:: 3.9
7474

75-
.. deprecated-removed:: 3.12 3.15
76-
*package* parameter was renamed to *anchor*. *anchor* can now be a
75+
.. versionchanged:: 3.12
76+
*package* parameter was renamed to *anchor*.
77+
*package* was still accepted, but deprecated.
78+
79+
.. versionchanged:: 3.15
80+
*package* parameter was fully removed. *anchor* can now be a
7781
non-package module and if omitted will default to the caller's module.
7882
*package* is no longer accepted since Python 3.15. Consider passing the
7983
anchor positionally or using ``importlib_resources >= 5.10`` for a

Doc/library/pprint.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ The formatted representation keeps objects on a single line if it can, and
2222
breaks them onto multiple lines if they don't fit within the allowed width,
2323
adjustable by the *width* parameter defaulting to 80 characters.
2424

25-
Dictionaries are sorted by key before the display is computed.
26-
2725
.. versionchanged:: 3.9
2826
Added support for pretty-printing :class:`types.SimpleNamespace`.
2927

Doc/library/pyexpat.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ XMLParser Objects
223223
Calling ``SetReparseDeferralEnabled(True)`` allows re-enabling reparse
224224
deferral.
225225

226-
Note that :meth:`SetReparseDeferralEnabled` has been backported to some
227-
prior releases of CPython as a security fix. Check for availability of
228-
:meth:`SetReparseDeferralEnabled` using :func:`hasattr` if used in code
229-
running across a variety of Python versions.
226+
:meth:`!SetReparseDeferralEnabled`
227+
has been backported to some prior releases of CPython as a security fix.
228+
Check for availability using :func:`hasattr` if used in code running
229+
across a variety of Python versions.
230230

231231
.. versionadded:: 3.13
232232

@@ -257,6 +257,11 @@ against some common XML vulnerabilities.
257257
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
258258
should not be used as they may have no special meaning.
259259

260+
:meth:`!SetBillionLaughsAttackProtectionActivationThreshold`
261+
has been backported to some prior releases of CPython as a security fix.
262+
Check for availability using :func:`hasattr` if used in code running
263+
across a variety of Python versions.
264+
260265
.. note::
261266

262267
Activation thresholds below 4 MiB are known to break support for DITA 1.3
@@ -288,6 +293,11 @@ against some common XML vulnerabilities.
288293
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
289294
should not be used as they may have no special meaning.
290295

296+
:meth:`!SetBillionLaughsAttackProtectionMaximumAmplification`
297+
has been backported to some prior releases of CPython as a security fix.
298+
Check for availability using :func:`hasattr` if used in code running
299+
across a variety of Python versions.
300+
291301
.. note::
292302

293303
The maximum amplification factor is only considered if the threshold
@@ -309,6 +319,11 @@ against some common XML vulnerabilities.
309319
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
310320
should not be used as they may have no special meaning.
311321

322+
:meth:`!SetAllocTrackerActivationThreshold`
323+
has been backported to some prior releases of CPython as a security fix.
324+
Check for availability using :func:`hasattr` if used in code running
325+
across a variety of Python versions.
326+
312327
.. versionadded:: next
313328

314329
.. method:: xmlparser.SetAllocTrackerMaximumAmplification(max_factor, /)
@@ -334,6 +349,11 @@ against some common XML vulnerabilities.
334349
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
335350
should not be used as they may have no special meaning.
336351

352+
:meth:`!SetAllocTrackerMaximumAmplification`
353+
has been backported to some prior releases of CPython as a security fix.
354+
Check for availability using :func:`hasattr` if used in code running
355+
across a variety of Python versions.
356+
337357
.. note::
338358

339359
The maximum amplification factor is only considered if the threshold

Doc/library/signal.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ The variables defined in the :mod:`signal` module are:
270270
All the signal numbers are defined symbolically. For example, the hangup signal
271271
is defined as :const:`signal.SIGHUP`; the variable names are identical to the
272272
names used in C programs, as found in ``<signal.h>``. The Unix man page for
273-
':c:func:`signal`' lists the existing signals (on some systems this is
273+
'``signal``' lists the existing signals (on some systems this is
274274
:manpage:`signal(2)`, on others the list is in :manpage:`signal(7)`). Note that
275275
not all systems define the same set of signal names; only those names defined by
276276
the system are defined by this module.
@@ -666,9 +666,8 @@ The :mod:`signal` module defines the following functions:
666666
*sigset*.
667667

668668
The return value is an object representing the data contained in the
669-
:c:type:`siginfo_t` structure, namely: :attr:`si_signo`, :attr:`si_code`,
670-
:attr:`si_errno`, :attr:`si_pid`, :attr:`si_uid`, :attr:`si_status`,
671-
:attr:`si_band`.
669+
``siginfo_t`` structure, namely: ``si_signo``, ``si_code``,
670+
``si_errno``, ``si_pid``, ``si_uid``, ``si_status``, ``si_band``.
672671

673672
.. availability:: Unix.
674673

0 commit comments

Comments
 (0)