Skip to content

Commit cdc79d2

Browse files
authored
Merge branch 'main' into pythongh-153668-msvc-arm64-numeric-lookup
2 parents aee3ab1 + 98bd716 commit cdc79d2

159 files changed

Lines changed: 5443 additions & 2460 deletions

File tree

Some content is hidden

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

‎.github/CODEOWNERS‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ Doc/library/tomllib.rst @encukou @hauntsaninja
598598
Lib/test/test_tomllib/ @encukou @hauntsaninja
599599
Lib/tomllib/ @encukou @hauntsaninja
600600

601+
# Turtle
602+
Doc/library/turtle.rst @StanFromIreland
603+
Doc/library/turtle-star.png @StanFromIreland
604+
Lib/test/test_turtle.py @StanFromIreland
605+
Lib/turtle.py @StanFromIreland
606+
601607
# Typing
602608
Doc/library/typing.rst @JelleZijlstra @AlexWaygood
603609
Lib/test/test_typing.py @JelleZijlstra @AlexWaygood
@@ -620,6 +626,12 @@ Lib/test/test_unittest/testmock/ @cjw296
620626
# Weakref
621627
**/*weakref* @kumaraditya303
622628

629+
# Zlib
630+
Doc/library/zlib.rst @StanFromIreland
631+
Lib/compression/zlib.py @StanFromIreland
632+
Lib/test/test_zlib.py @StanFromIreland
633+
Modules/_zlibmodule.c @StanFromIreland
634+
623635
# Zipfile.Path
624636
Lib/test/test_zipfile/_path/ @jaraco
625637
Lib/zipfile/_path/ @jaraco

‎Doc/Makefile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ help:
3232
@echo "Please use \`make <target>' where <target> is one of"
3333
@echo " clean to remove build files"
3434
@echo " venv to create a venv with necessary tools"
35+
@echo " lock to regenerate the pinned dependencies in $(REQUIREMENTS)"
3536
@echo " html to make standalone HTML files"
3637
@echo " gettext to generate POT files"
3738
@echo " htmlview to open the index page built by the html target in your browser"
@@ -185,6 +186,19 @@ venv:
185186
echo "The venv has been created in the $(VENVDIR) directory"; \
186187
fi
187188

189+
.PHONY: lock
190+
lock:
191+
# Dependencies have a 14 day cooldown period to mitigate supply chain attacks,
192+
# except for sphinx_linklint and python-docs-theme, which are maintained by
193+
# core team members.
194+
uv pip compile requirements.txt \
195+
--exclude-newer P14D \
196+
--exclude-newer-package sphinx_linklint=PT0S \
197+
--exclude-newer-package python-docs-theme=PT0S \
198+
--no-cache --output-file $(REQUIREMENTS) \
199+
--python-version 3.12 --universal \
200+
--custom-compile-command="make lock"
201+
188202
.PHONY: dist-no-html
189203
dist-no-html: dist-text dist-epub dist-texinfo
190204

‎Doc/conf.py‎

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

4242
# Skip if downstream redistributors haven't installed them
4343
_OPTIONAL_EXTENSIONS = (
44-
'linklint.ext',
44+
'sphinx_linklint.ext',
4545
'notfound.extension',
4646
'sphinxext.opengraph',
4747
'sphinxcontrib.rsvgconverter',

‎Doc/faq/design.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ tuples, but not lists, can be used as keys. Note, however, that a tuple is
430430
only hashable if all of its elements are hashable.
431431

432432

433+
.. _how-are-lists-implemented:
434+
433435
How are lists implemented in CPython?
434436
-------------------------------------
435437

@@ -445,6 +447,10 @@ cleverness is applied to improve the performance of appending items repeatedly;
445447
when the array must be grown, some extra space is allocated so the next few
446448
times don't require an actual resize.
447449

450+
See :ref:`time-complexity` for the costs of the various list operations.
451+
452+
453+
.. _how-are-dictionaries-implemented:
448454

449455
How are dictionaries implemented in CPython?
450456
--------------------------------------------
@@ -462,6 +468,8 @@ internal array where the value will be stored. Assuming that you're storing
462468
keys that all have different hash values, this means that dictionaries take
463469
constant time -- *O*\ (1), in Big-O notation -- to retrieve a key.
464470

471+
See :ref:`time-complexity` for the costs of the various dictionary operations.
472+
465473

466474
Why must dictionary keys be immutable?
467475
--------------------------------------

‎Doc/faq/programming.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ What is the most efficient way to concatenate many strings together?
11361136
:class:`str` and :class:`bytes` objects are immutable, therefore concatenating
11371137
many strings together is inefficient as each concatenation creates a new
11381138
object. In the general case, the total runtime cost is quadratic in the
1139-
total string length.
1139+
total string length. See :ref:`time-complexity` for more information.
11401140

11411141
To accumulate many :class:`str` objects, the recommended idiom is to place
11421142
them into a list and call :meth:`str.join` at the end::

‎Doc/glossary.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ Glossary
509509
A piece of syntax which can be evaluated to some value. In other words,
510510
an expression is an accumulation of expression elements like literals,
511511
names, attribute access, operators or function calls which all return a
512-
value. In contrast to many other languages, not all language constructs
512+
value. Not all language constructs
513513
are expressions. There are also :term:`statement`\s which cannot be used
514514
as expressions, such as :keyword:`while`. Assignments are also statements,
515515
not expressions.
@@ -942,7 +942,7 @@ Glossary
942942
list
943943
A built-in Python :term:`sequence`. Despite its name it is more akin
944944
to an array in other languages than to a linked list since access to
945-
elements is *O*\ (1).
945+
elements is *O*\ (1). See :ref:`time-complexity`.
946946

947947
list comprehension
948948
A compact way to process all or part of the elements in a sequence and

‎Doc/library/asyncio-stream.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ and work with streams:
4949

5050

5151
.. function:: open_connection(host=None, port=None, *, \
52-
limit=None, ssl=None, family=0, proto=0, \
52+
limit=65536, ssl=None, family=0, proto=0, \
5353
flags=0, sock=None, local_addr=None, \
5454
server_hostname=None, ssl_handshake_timeout=None, \
5555
ssl_shutdown_timeout=None, \
@@ -89,7 +89,7 @@ and work with streams:
8989

9090

9191
.. function:: start_server(client_connected_cb, host=None, \
92-
port=None, *, limit=None, \
92+
port=None, *, limit=65536, \
9393
family=socket.AF_UNSPEC, \
9494
flags=socket.AI_PASSIVE, sock=None, \
9595
backlog=100, ssl=None, reuse_address=None, \
@@ -137,7 +137,7 @@ and work with streams:
137137

138138
.. rubric:: Unix Sockets
139139

140-
.. function:: open_unix_connection(path=None, *, limit=None, \
140+
.. function:: open_unix_connection(path=None, *, limit=65536, \
141141
ssl=None, sock=None, server_hostname=None, \
142142
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)
143143
:async:
@@ -169,7 +169,7 @@ and work with streams:
169169

170170

171171
.. function:: start_unix_server(client_connected_cb, path=None, \
172-
*, limit=None, sock=None, backlog=100, ssl=None, \
172+
*, limit=65536, sock=None, backlog=100, ssl=None, \
173173
ssl_handshake_timeout=None, \
174174
ssl_shutdown_timeout=None, start_serving=True, \
175175
cleanup_socket=True, mode=None)

‎Doc/library/asyncio-subprocess.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Creating Subprocesses
6262
=====================
6363

6464
.. function:: create_subprocess_exec(program, *args, stdin=None, \
65-
stdout=None, stderr=None, limit=None, **kwds)
65+
stdout=None, stderr=None, limit=65536, **kwds)
6666
:async:
6767
6868
Create a subprocess.
@@ -84,7 +84,7 @@ Creating Subprocesses
8484

8585

8686
.. function:: create_subprocess_shell(cmd, stdin=None, \
87-
stdout=None, stderr=None, limit=None, **kwds)
87+
stdout=None, stderr=None, limit=65536, **kwds)
8888
:async:
8989
9090
Run the *cmd* shell command.

‎Doc/library/asyncio-task.rst‎

Lines changed: 74 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -402,69 +402,85 @@ Example::
402402
task2 = tg.create_task(another_coro(...))
403403
print(f"Both tasks have completed now: {task1.result()}, {task2.result()}")
404404

405-
The ``async with`` statement will wait for all tasks in the group to finish.
406-
While waiting, new tasks may still be added to the group
407-
(for example, by passing ``tg`` into one of the coroutines
408-
and calling ``tg.create_task()`` in that coroutine). There is also opportunity to
409-
request termination of the entire task group with ``tg.cancel()``, based on some condition.
410-
Once the last task has finished and the ``async with`` block is exited,
411-
no new tasks may be added to the group.
412-
413-
The first time any of the tasks belonging to the group fails
414-
with an exception other than :exc:`asyncio.CancelledError`,
415-
the remaining tasks in the group are cancelled.
416-
No further tasks can then be added to the group.
417-
At this point, if the body of the ``async with`` statement is still active
418-
(i.e., :meth:`~object.__aexit__` hasn't been called yet),
419-
the task directly containing the ``async with`` statement is also cancelled.
420-
The resulting :exc:`asyncio.CancelledError` will interrupt an ``await``,
421-
but it will not bubble out of the containing ``async with`` statement.
422-
423-
Once all tasks have finished, if any tasks have failed
424-
with an exception other than :exc:`asyncio.CancelledError`,
425-
those exceptions are combined in an
426-
:exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`
427-
(as appropriate; see their documentation)
428-
which is then raised.
429-
430-
Two base exceptions are treated specially:
431-
If any task fails with :exc:`KeyboardInterrupt` or :exc:`SystemExit`,
432-
the task group still cancels the remaining tasks and waits for them,
433-
but then the initial :exc:`KeyboardInterrupt` or :exc:`SystemExit`
434-
is re-raised instead of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`.
435-
436-
If the body of the ``async with`` statement exits with an exception
437-
(so :meth:`~object.__aexit__` is called with an exception set),
438-
this is treated the same as if one of the tasks failed:
439-
the remaining tasks are cancelled and then waited for,
440-
and non-cancellation exceptions are grouped into an
441-
exception group and raised.
442-
The exception passed into :meth:`~object.__aexit__`,
443-
unless it is :exc:`asyncio.CancelledError`,
444-
is also included in the exception group.
445-
The same special case is made for
446-
:exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph.
447-
There is an additional special case made only for the body of the
448-
``async with``: if it raises :exc:`GeneratorExit` and none of the
449-
other tasks raise exceptions that would be reported, then the
450-
:exc:`GeneratorExit` is reraised.
451-
452-
Task groups are careful not to mix up the internal cancellation used to
453-
"wake up" their :meth:`~object.__aexit__` with cancellation requests
454-
for the task in which they are running made by other parties.
405+
A few points to keep in mind when using task groups:
406+
407+
* The ``async with`` statement will wait for all tasks in the group
408+
to finish. While waiting, new tasks may still be added to the group
409+
(for example, by passing ``tg`` into one of the coroutines and
410+
calling ``tg.create_task()`` in that coroutine); once the last task
411+
has finished and the ``async with`` block is exited, no new tasks
412+
may be added.
413+
414+
* Termination of the entire task group may be requested with
415+
``tg.cancel()``, based on some condition.
416+
417+
* If the group is shut down (e.g. because another task failed) before
418+
a newly created task has started running, the task is cancelled
419+
without its coroutine executing at all, not even to its first
420+
``await``. To guarantee that the coroutine starts, create the task
421+
eagerly with ``eager_start=True`` or use
422+
:func:`asyncio.eager_task_factory`. For example::
423+
424+
async def job():
425+
print("job started") # never printed
426+
try:
427+
await asyncio.sleep(1)
428+
finally:
429+
print("job cleaned up") # never printed
430+
431+
async def main():
432+
async with asyncio.TaskGroup() as tg:
433+
tg.create_task(job())
434+
raise RuntimeError # shuts down the group before job() runs
435+
436+
With ``tg.create_task(job(), eager_start=True)``, ``job()`` runs up
437+
to the ``await``, is cancelled there, and both messages are printed.
438+
439+
When any of the tasks belonging to the group fails with an exception
440+
other than :exc:`asyncio.CancelledError` (or the body of the
441+
``async with`` statement exits with an exception, which is treated
442+
the same way):
443+
444+
* The first time this happens, the remaining tasks in the group are
445+
cancelled and then waited for, and no further tasks can be added to
446+
the group. If the body of the ``async with`` statement is still
447+
active (i.e., :meth:`~object.__aexit__` hasn't been called yet),
448+
the task directly containing the ``async with`` statement is also
449+
cancelled. The resulting :exc:`asyncio.CancelledError` will
450+
interrupt an ``await``, but it will not bubble out of the containing
451+
``async with`` statement.
452+
453+
* Once all tasks have finished, the non-cancellation exceptions --
454+
including the exception the body exited with, unless it is
455+
:exc:`asyncio.CancelledError` -- are combined in an
456+
:exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`
457+
(as appropriate; see their documentation), which is then raised.
458+
459+
* Some exceptions are treated specially: if any task fails with
460+
:exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still
461+
cancels the remaining tasks and waits for them, but then the initial
462+
:exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead
463+
of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`.
464+
Additionally, if the body of the ``async with`` statement raises
465+
:exc:`GeneratorExit` and none of the other tasks raise exceptions
466+
that would be reported, the :exc:`GeneratorExit` is re-raised.
467+
468+
Task groups are careful not to mix up the internal cancellation used
469+
to "wake up" their :meth:`~object.__aexit__` with cancellation
470+
requests for the task in which they are running made by other parties.
455471
In particular, when one task group is syntactically nested in another,
456-
and both experience an exception in one of their child tasks simultaneously,
457-
the inner task group will process its exceptions, and then the outer task group
458-
will receive another cancellation and process its own exceptions.
472+
and both experience an exception in one of their child tasks
473+
simultaneously, the inner task group will process its exceptions, and
474+
then the outer task group will receive another cancellation and
475+
process its own exceptions.
459476

460477
In the case where a task group is cancelled externally and also must
461478
raise an :exc:`ExceptionGroup`, it will call the parent task's
462-
:meth:`~asyncio.Task.cancel` method. This ensures that a
479+
:meth:`~asyncio.Task.cancel` method. This ensures that a
463480
:exc:`asyncio.CancelledError` will be raised at the next
464-
:keyword:`await`, so the cancellation is not lost.
465-
466-
Task groups preserve the cancellation count
467-
reported by :meth:`asyncio.Task.cancelling`.
481+
:keyword:`await`, so the cancellation is not lost. Task groups also
482+
preserve the cancellation count reported by
483+
:meth:`asyncio.Task.cancelling`.
468484

469485
.. versionchanged:: 3.13
470486

0 commit comments

Comments
 (0)