Skip to content

Commit 6733910

Browse files
authored
Merge branch 'main' into eager-tasks
2 parents 8493e59 + 64173cd commit 6733910

File tree

5 files changed

+95
-36
lines changed

5 files changed

+95
-36
lines changed

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,35 @@ Pending removal in Python 3.16
1919
* :mod:`asyncio`:
2020

2121
* :func:`!asyncio.iscoroutinefunction` is deprecated
22-
and will be removed in Python 3.16,
22+
and will be removed in Python 3.16;
2323
use :func:`inspect.iscoroutinefunction` instead.
2424
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
2525

26+
* :mod:`asyncio` policy system is deprecated and will be removed in Python 3.16.
27+
In particular, the following classes and functions are deprecated:
28+
29+
* :class:`asyncio.AbstractEventLoopPolicy`
30+
* :class:`asyncio.DefaultEventLoopPolicy`
31+
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
32+
* :class:`asyncio.WindowsProactorEventLoopPolicy`
33+
* :func:`asyncio.get_event_loop_policy`
34+
* :func:`asyncio.set_event_loop_policy`
35+
* :func:`asyncio.set_event_loop`
36+
37+
Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
38+
*loop_factory* to use the desired event loop implementation.
39+
40+
For example, to use :class:`asyncio.SelectorEventLoop` on Windows::
41+
42+
import asyncio
43+
44+
async def main():
45+
...
46+
47+
asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)
48+
49+
(Contributed by Kumar Aditya in :gh:`127949`.)
50+
2651
* :mod:`builtins`:
2752

2853
* Bitwise inversion on boolean types, ``~True`` or ``~False``

Doc/library/asyncio-eventloop.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ an event loop:
6262
.. versionchanged:: 3.14
6363
Raises a :exc:`RuntimeError` if there is no current event loop.
6464

65+
.. note::
66+
67+
The :mod:`!asyncio` policy system is deprecated and will be removed
68+
in Python 3.16; from there on, this function will always return the
69+
running event loop.
70+
71+
6572
.. function:: set_event_loop(loop)
6673

6774
Set *loop* as the current event loop for the current OS thread.
@@ -1781,12 +1788,11 @@ By default asyncio is configured to use :class:`EventLoop`.
17811788
import asyncio
17821789
import selectors
17831790

1784-
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1785-
def new_event_loop(self):
1786-
selector = selectors.SelectSelector()
1787-
return asyncio.SelectorEventLoop(selector)
1791+
async def main():
1792+
...
17881793

1789-
asyncio.set_event_loop_policy(MyPolicy())
1794+
loop_factory = lambda: asyncio.SelectorEventLoop(selectors.SelectSelector())
1795+
asyncio.run(main(), loop_factory=loop_factory)
17901796

17911797

17921798
.. availability:: Unix, Windows.

Doc/library/asyncio-runner.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ Running an asyncio Program
8686

8787
Added *eager_tasks* parameter.
8888

89+
.. note::
90+
91+
The :mod:`!asyncio` policy system is deprecated and will be removed
92+
in Python 3.16; from there on, an explicit *loop_factory* is needed
93+
to configure the event loop.
94+
8995

9096
Runner context manager
9197
======================

Lib/http/__init__.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def is_server_error(self):
5454
CONTINUE = 100, 'Continue', 'Request received, please continue'
5555
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',
5656
'Switching to new protocol; obey Upgrade header')
57-
PROCESSING = 102, 'Processing'
58-
EARLY_HINTS = 103, 'Early Hints'
57+
PROCESSING = 102, 'Processing', 'Server is processing the request'
58+
EARLY_HINTS = (103, 'Early Hints',
59+
'Headers sent to prepare for the response')
5960

6061
# success
6162
OK = 200, 'OK', 'Request fulfilled, document follows'
@@ -67,9 +68,11 @@ def is_server_error(self):
6768
NO_CONTENT = 204, 'No Content', 'Request fulfilled, nothing follows'
6869
RESET_CONTENT = 205, 'Reset Content', 'Clear input form for further input'
6970
PARTIAL_CONTENT = 206, 'Partial Content', 'Partial content follows'
70-
MULTI_STATUS = 207, 'Multi-Status'
71-
ALREADY_REPORTED = 208, 'Already Reported'
72-
IM_USED = 226, 'IM Used'
71+
MULTI_STATUS = (207, 'Multi-Status',
72+
'Response contains multiple statuses in the body')
73+
ALREADY_REPORTED = (208, 'Already Reported',
74+
'Operation has already been reported')
75+
IM_USED = 226, 'IM Used', 'Request completed using instance manipulations'
7376

7477
# redirection
7578
MULTIPLE_CHOICES = (300, 'Multiple Choices',
@@ -128,15 +131,19 @@ def is_server_error(self):
128131
EXPECTATION_FAILED = (417, 'Expectation Failed',
129132
'Expect condition could not be satisfied')
130133
IM_A_TEAPOT = (418, 'I\'m a Teapot',
131-
'Server refuses to brew coffee because it is a teapot.')
134+
'Server refuses to brew coffee because it is a teapot')
132135
MISDIRECTED_REQUEST = (421, 'Misdirected Request',
133136
'Server is not able to produce a response')
134-
UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content'
137+
UNPROCESSABLE_CONTENT = (422, 'Unprocessable Content',
138+
'Server is not able to process the contained instructions')
135139
UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT
136-
LOCKED = 423, 'Locked'
137-
FAILED_DEPENDENCY = 424, 'Failed Dependency'
138-
TOO_EARLY = 425, 'Too Early'
139-
UPGRADE_REQUIRED = 426, 'Upgrade Required'
140+
LOCKED = 423, 'Locked', 'Resource of a method is locked'
141+
FAILED_DEPENDENCY = (424, 'Failed Dependency',
142+
'Dependent action of the request failed')
143+
TOO_EARLY = (425, 'Too Early',
144+
'Server refuses to process a request that might be replayed')
145+
UPGRADE_REQUIRED = (426, 'Upgrade Required',
146+
'Server refuses to perform the request using the current protocol')
140147
PRECONDITION_REQUIRED = (428, 'Precondition Required',
141148
'The origin server requires the request to be conditional')
142149
TOO_MANY_REQUESTS = (429, 'Too Many Requests',
@@ -164,10 +171,14 @@ def is_server_error(self):
164171
'The gateway server did not receive a timely response')
165172
HTTP_VERSION_NOT_SUPPORTED = (505, 'HTTP Version Not Supported',
166173
'Cannot fulfill request')
167-
VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates'
168-
INSUFFICIENT_STORAGE = 507, 'Insufficient Storage'
169-
LOOP_DETECTED = 508, 'Loop Detected'
170-
NOT_EXTENDED = 510, 'Not Extended'
174+
VARIANT_ALSO_NEGOTIATES = (506, 'Variant Also Negotiates',
175+
'Server has an internal configuration error')
176+
INSUFFICIENT_STORAGE = (507, 'Insufficient Storage',
177+
'Server is not able to store the representation')
178+
LOOP_DETECTED = (508, 'Loop Detected',
179+
'Server encountered an infinite loop while processing a request')
180+
NOT_EXTENDED = (510, 'Not Extended',
181+
'Request does not meet the resource access policy')
171182
NETWORK_AUTHENTICATION_REQUIRED = (511,
172183
'Network Authentication Required',
173184
'The client needs to authenticate to gain network access')

Lib/test/test_httplib.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,9 @@ def is_server_error(self):
594594
CONTINUE = 100, 'Continue', 'Request received, please continue'
595595
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',
596596
'Switching to new protocol; obey Upgrade header')
597-
PROCESSING = 102, 'Processing'
598-
EARLY_HINTS = 103, 'Early Hints'
597+
PROCESSING = 102, 'Processing', 'Server is processing the request'
598+
EARLY_HINTS = (103, 'Early Hints',
599+
'Headers sent to prepare for the response')
599600
# success
600601
OK = 200, 'OK', 'Request fulfilled, document follows'
601602
CREATED = 201, 'Created', 'Document created, URL follows'
@@ -606,9 +607,11 @@ def is_server_error(self):
606607
NO_CONTENT = 204, 'No Content', 'Request fulfilled, nothing follows'
607608
RESET_CONTENT = 205, 'Reset Content', 'Clear input form for further input'
608609
PARTIAL_CONTENT = 206, 'Partial Content', 'Partial content follows'
609-
MULTI_STATUS = 207, 'Multi-Status'
610-
ALREADY_REPORTED = 208, 'Already Reported'
611-
IM_USED = 226, 'IM Used'
610+
MULTI_STATUS = (207, 'Multi-Status',
611+
'Response contains multiple statuses in the body')
612+
ALREADY_REPORTED = (208, 'Already Reported',
613+
'Operation has already been reported')
614+
IM_USED = 226, 'IM Used', 'Request completed using instance manipulations'
612615
# redirection
613616
MULTIPLE_CHOICES = (300, 'Multiple Choices',
614617
'Object has several resources -- see URI list')
@@ -665,15 +668,19 @@ def is_server_error(self):
665668
EXPECTATION_FAILED = (417, 'Expectation Failed',
666669
'Expect condition could not be satisfied')
667670
IM_A_TEAPOT = (418, 'I\'m a Teapot',
668-
'Server refuses to brew coffee because it is a teapot.')
671+
'Server refuses to brew coffee because it is a teapot')
669672
MISDIRECTED_REQUEST = (421, 'Misdirected Request',
670673
'Server is not able to produce a response')
671-
UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content'
674+
UNPROCESSABLE_CONTENT = (422, 'Unprocessable Content',
675+
'Server is not able to process the contained instructions')
672676
UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT
673-
LOCKED = 423, 'Locked'
674-
FAILED_DEPENDENCY = 424, 'Failed Dependency'
675-
TOO_EARLY = 425, 'Too Early'
676-
UPGRADE_REQUIRED = 426, 'Upgrade Required'
677+
LOCKED = 423, 'Locked', 'Resource of a method is locked'
678+
FAILED_DEPENDENCY = (424, 'Failed Dependency',
679+
'Dependent action of the request failed')
680+
TOO_EARLY = (425, 'Too Early',
681+
'Server refuses to process a request that might be replayed')
682+
UPGRADE_REQUIRED = (426, 'Upgrade Required',
683+
'Server refuses to perform the request using the current protocol')
677684
PRECONDITION_REQUIRED = (428, 'Precondition Required',
678685
'The origin server requires the request to be conditional')
679686
TOO_MANY_REQUESTS = (429, 'Too Many Requests',
@@ -700,10 +707,14 @@ def is_server_error(self):
700707
'The gateway server did not receive a timely response')
701708
HTTP_VERSION_NOT_SUPPORTED = (505, 'HTTP Version Not Supported',
702709
'Cannot fulfill request')
703-
VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates'
704-
INSUFFICIENT_STORAGE = 507, 'Insufficient Storage'
705-
LOOP_DETECTED = 508, 'Loop Detected'
706-
NOT_EXTENDED = 510, 'Not Extended'
710+
VARIANT_ALSO_NEGOTIATES = (506, 'Variant Also Negotiates',
711+
'Server has an internal configuration error')
712+
INSUFFICIENT_STORAGE = (507, 'Insufficient Storage',
713+
'Server is not able to store the representation')
714+
LOOP_DETECTED = (508, 'Loop Detected',
715+
'Server encountered an infinite loop while processing a request')
716+
NOT_EXTENDED = (510, 'Not Extended',
717+
'Request does not meet the resource access policy')
707718
NETWORK_AUTHENTICATION_REQUIRED = (511,
708719
'Network Authentication Required',
709720
'The client needs to authenticate to gain network access')

0 commit comments

Comments
 (0)