Skip to content

Commit 79acbaf

Browse files
authored
Merge branch 'main' into cmath-ValueError/133895
2 parents 76a79fc + f71c96c commit 79acbaf

File tree

151 files changed

+2987
-1668
lines changed

Some content is hidden

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

151 files changed

+2987
-1668
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/bytes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Create, Finish, Discard
260260
writer size to *size*. The caller is responsible to write *size*
261261
bytes using :c:func:`PyBytesWriter_GetData`.
262262
263-
On error, set an exception and return NULL.
263+
On error, set an exception and return ``NULL``.
264264
265265
*size* must be positive or zero.
266266

Doc/c-api/function.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ There are a few functions specific to Python functions.
175175
176176
.. versionadded:: 3.12
177177
178+
- ``PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME``
179+
180+
.. versionadded:: 3.15
178181
179182
.. c:type:: int (*PyFunction_WatchCallback)(PyFunction_WatchEvent event, PyFunctionObject *func, PyObject *new_value)
180183

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ Object Protocol
600600
601601
Clear the managed dictionary of *obj*.
602602
603-
This function must only be called in a traverse function of the type which
603+
This function must only be called in a clear function of the type which
604604
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
605605
606606
.. versionadded:: 3.13

Doc/c-api/tuple.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ Tuple Objects
3737
or ``NULL`` with an exception set on failure.
3838
3939
40+
.. c:function:: PyObject* PyTuple_FromArray(PyObject *const *array, Py_ssize_t size)
41+
42+
Create a tuple of *size* items and copy references from *array* to the new
43+
tuple.
44+
45+
*array* can be NULL if *size* is ``0``.
46+
47+
On success, return a new reference.
48+
On error, set an exception and return ``NULL``.
49+
50+
.. versionadded:: next
51+
52+
4053
.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
4154
4255
Return a new tuple object of size *n*,

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
@@ -346,7 +346,7 @@ Constants
346346
.. data:: nan
347347

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

351351
.. versionadded:: 3.6
352352

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

0 commit comments

Comments
 (0)