Skip to content

Commit b139e4c

Browse files
authored
Merge branch 'main' into pythongh-87695-glob-oserror-long-symlink
2 parents d5f637a + 7a3b035 commit b139e4c

File tree

138 files changed

+3865
-1634
lines changed

Some content is hidden

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

138 files changed

+3865
-1634
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# GitHub
88
.github/** @ezio-melotti @hugovk
99

10+
# pre-commit
11+
.pre-commit-config.yaml @hugovk @AlexWaygood
12+
1013
# Build system
1114
configure* @erlend-aasland @corona10
1215

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
permissions:
6+
contents: read
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 10
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.x"
22+
- uses: pre-commit/[email protected]

.github/workflows/require-pr-label.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
types: [opened, reopened, labeled, unlabeled, synchronize]
66

7+
permissions:
8+
issues: read
9+
pull-requests: read
10+
711
jobs:
812
label:
913
name: DO-NOT-MERGE / unresolved review

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-yaml
6+
- id: trailing-whitespace
7+
types_or: [c, python, rst]

Doc/howto/logging.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ The flow of log event information in loggers and handlers is illustrated in the
418418
following diagram.
419419

420420
.. image:: logging_flow.png
421+
:class: invert-in-dark-mode
421422

422423
Loggers
423424
^^^^^^^

Doc/library/asyncio-task.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ Running Tasks Concurrently
527527
and there is no running event loop.
528528

529529

530+
.. _eager-task-factory:
531+
530532
Eager Task Factory
531533
==================
532534

@@ -560,6 +562,13 @@ Eager Task Factory
560562
using the provided *custom_task_constructor* when creating a new task instead
561563
of the default :class:`Task`.
562564

565+
*custom_task_constructor* must be a *callable* with the signature matching
566+
the signature of :class:`Task.__init__ <Task>`.
567+
The callable must return a :class:`asyncio.Task`-compatible object.
568+
569+
This function returns a *callable* intended to be used as a task factory of an
570+
event loop via :meth:`loop.set_task_factory(factory) <loop.set_task_factory>`).
571+
563572
.. versionadded:: 3.12
564573

565574

@@ -1014,7 +1023,7 @@ Introspection
10141023
Task Object
10151024
===========
10161025

1017-
.. class:: Task(coro, *, loop=None, name=None, context=None)
1026+
.. class:: Task(coro, *, loop=None, name=None, context=None, eager_start=False)
10181027

10191028
A :class:`Future-like <Future>` object that runs a Python
10201029
:ref:`coroutine <coroutine>`. Not thread-safe.
@@ -1054,6 +1063,13 @@ Task Object
10541063
If no *context* is provided, the Task copies the current context
10551064
and later runs its coroutine in the copied context.
10561065

1066+
An optional keyword-only *eager_start* argument allows eagerly starting
1067+
the execution of the :class:`asyncio.Task` at task creation time.
1068+
If set to ``True`` and the event loop is running, the task will start
1069+
executing the coroutine immediately, until the first time the coroutine
1070+
blocks. If the coroutine returns or raises without blocking, the task
1071+
will be finished eagerly and will skip scheduling to the event loop.
1072+
10571073
.. versionchanged:: 3.7
10581074
Added support for the :mod:`contextvars` module.
10591075

@@ -1067,6 +1083,9 @@ Task Object
10671083
.. versionchanged:: 3.11
10681084
Added the *context* parameter.
10691085

1086+
.. versionchanged:: 3.12
1087+
Added the *eager_start* parameter.
1088+
10701089
.. method:: done()
10711090

10721091
Return ``True`` if the Task is *done*.
@@ -1157,8 +1176,17 @@ Task Object
11571176

11581177
Return the coroutine object wrapped by the :class:`Task`.
11591178

1179+
.. note::
1180+
1181+
This will return ``None`` for Tasks which have already
1182+
completed eagerly. See the :ref:`Eager Task Factory <eager-task-factory>`.
1183+
11601184
.. versionadded:: 3.8
11611185

1186+
.. versionchanged:: 3.12
1187+
1188+
Newly added eager task execution means result may be ``None``.
1189+
11621190
.. method:: get_context()
11631191

11641192
Return the :class:`contextvars.Context` object

Doc/library/bisect.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ method to determine whether a value has been found. Instead, the
2424
functions only call the :meth:`__lt__` method and will return an insertion
2525
point between values in an array.
2626

27+
.. _bisect functions:
28+
2729
The following functions are provided:
2830

2931

@@ -55,7 +57,7 @@ The following functions are provided:
5557
.. function:: bisect_right(a, x, lo=0, hi=len(a), *, key=None)
5658
bisect(a, x, lo=0, hi=len(a), *, key=None)
5759
58-
Similar to :func:`bisect_left`, but returns an insertion point which comes
60+
Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point which comes
5961
after (to the right of) any existing entries of *x* in *a*.
6062

6163
The returned insertion point *ip* partitions the array *a* into two slices
@@ -70,7 +72,7 @@ The following functions are provided:
7072

7173
Insert *x* in *a* in sorted order.
7274

73-
This function first runs :func:`bisect_left` to locate an insertion point.
75+
This function first runs :py:func:`~bisect.bisect_left` to locate an insertion point.
7476
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
7577
appropriate position to maintain sort order.
7678

@@ -87,10 +89,10 @@ The following functions are provided:
8789
.. function:: insort_right(a, x, lo=0, hi=len(a), *, key=None)
8890
insort(a, x, lo=0, hi=len(a), *, key=None)
8991
90-
Similar to :func:`insort_left`, but inserting *x* in *a* after any existing
92+
Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after any existing
9193
entries of *x*.
9294

93-
This function first runs :func:`bisect_right` to locate an insertion point.
95+
This function first runs :py:func:`~bisect.bisect_right` to locate an insertion point.
9496
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
9597
appropriate position to maintain sort order.
9698

@@ -120,7 +122,7 @@ thoughts in mind:
120122
they are used. Consequently, if the search functions are used in a loop,
121123
the key function may be called again and again on the same array elements.
122124
If the key function isn't fast, consider wrapping it with
123-
:func:`functools.cache` to avoid duplicate computations. Alternatively,
125+
:py:func:`functools.cache` to avoid duplicate computations. Alternatively,
124126
consider searching an array of precomputed keys to locate the insertion
125127
point (as shown in the examples section below).
126128

@@ -140,7 +142,7 @@ thoughts in mind:
140142
Searching Sorted Lists
141143
----------------------
142144

143-
The above :func:`bisect` functions are useful for finding insertion points but
145+
The above `bisect functions`_ are useful for finding insertion points but
144146
can be tricky or awkward to use for common searching tasks. The following five
145147
functions show how to transform them into the standard lookups for sorted
146148
lists::
@@ -186,8 +188,8 @@ Examples
186188

187189
.. _bisect-example:
188190

189-
The :func:`bisect` function can be useful for numeric table lookups. This
190-
example uses :func:`bisect` to look up a letter grade for an exam score (say)
191+
The :py:func:`~bisect.bisect` function can be useful for numeric table lookups. This
192+
example uses :py:func:`~bisect.bisect` to look up a letter grade for an exam score (say)
191193
based on a set of ordered numeric breakpoints: 90 and up is an 'A', 80 to 89 is
192194
a 'B', and so on::
193195

@@ -198,8 +200,8 @@ a 'B', and so on::
198200
>>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
199201
['F', 'A', 'C', 'C', 'B', 'A', 'A']
200202

201-
The :func:`bisect` and :func:`insort` functions also work with lists of
202-
tuples. The *key* argument can serve to extract the field used for ordering
203+
The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also work with
204+
lists of tuples. The *key* argument can serve to extract the field used for ordering
203205
records in a table::
204206

205207
>>> from collections import namedtuple

Doc/library/dis.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,14 @@ iterations of the loop.
11961196

11971197
.. versionadded:: 3.12
11981198

1199+
.. opcode:: LOAD_FAST_AND_CLEAR (var_num)
1200+
1201+
Pushes a reference to the local ``co_varnames[var_num]`` onto the stack (or
1202+
pushes ``NULL`` onto the stack if the local variable has not been
1203+
initialized) and sets ``co_varnames[var_num]`` to ``NULL``.
1204+
1205+
.. versionadded:: 3.12
1206+
11991207
.. opcode:: STORE_FAST (var_num)
12001208

12011209
Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``.

Doc/library/hashlib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ Constructor functions also accept the following tree hashing parameters:
430430

431431
.. figure:: hashlib-blake2-tree.png
432432
:alt: Explanation of tree mode parameters.
433+
:class: invert-in-dark-mode
433434

434435
See section 2.10 in `BLAKE2 specification
435436
<https://www.blake2.net/blake2_20130129.pdf>`_ for comprehensive review of tree

Doc/library/http.client.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ HTTPConnection Objects
264264
encode_chunked=False)
265265

266266
This will send a request to the server using the HTTP request
267-
method *method* and the selector *url*.
267+
method *method* and the request URI *url*. The provided *url* must be
268+
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
269+
(unless connecting to an HTTP proxy server or using the ``OPTIONS`` or
270+
``CONNECT`` methods).
268271

269272
If *body* is specified, the specified data is sent after the headers are
270273
finished. It may be a :class:`str`, a :term:`bytes-like object`, an
@@ -279,7 +282,10 @@ HTTPConnection Objects
279282
iterable are sent as is until the iterable is exhausted.
280283

281284
The *headers* argument should be a mapping of extra HTTP headers to send
282-
with the request.
285+
with the request. A :rfc:`Host header <2616#section-14.23>`
286+
must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
287+
(unless connecting to an HTTP proxy server or using the ``OPTIONS`` or
288+
``CONNECT`` methods).
283289

284290
If *headers* contains neither Content-Length nor Transfer-Encoding,
285291
but there is a request body, one of those
@@ -298,6 +304,16 @@ HTTPConnection Objects
298304
HTTPConnection object assumes that all encoding is handled by the
299305
calling code. If it is ``True``, the body will be chunk-encoded.
300306

307+
For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::
308+
309+
>>> import http.client
310+
>>> host = "docs.python.org"
311+
>>> conn = http.client.HTTPSConnection(host)
312+
>>> conn.request("GET", "/3/", headers={"Host": host})
313+
>>> response = conn.getresponse()
314+
>>> print(response.status, response.reason)
315+
200 OK
316+
301317
.. note::
302318
Chunked transfer encoding has been added to the HTTP protocol
303319
version 1.1. Unless the HTTP server is known to handle HTTP 1.1,

0 commit comments

Comments
 (0)