Skip to content

Commit c9c4808

Browse files
authored
Merge branch 'main' into wasi-emscripten-pdb
2 parents 2cb8267 + aeb9b65 commit c9c4808

25 files changed

+284
-85
lines changed

Doc/c-api/object.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ Object Protocol
111111
.. note::
112112
113113
Exceptions that occur when this calls :meth:`~object.__getattr__` and
114-
:meth:`~object.__getattribute__` methods are silently ignored.
114+
:meth:`~object.__getattribute__` methods aren't propagated,
115+
but instead given to :func:`sys.unraisablehook`.
115116
For proper error handling, use :c:func:`PyObject_HasAttrWithError`,
116117
:c:func:`PyObject_GetOptionalAttr` or :c:func:`PyObject_GetAttr` instead.
117118

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
10231023
:c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the
10241024
:c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have
10251025
``NULL`` values.
1026+
10261027
.. XXX are most flag bits *really* inherited individually?
10271028
10281029
**Default:**

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-policy.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
Policies
88
========
99

10+
.. warning::
11+
12+
Policies are deprecated and will be removed in Python 3.16.
13+
Users are encouraged to use the :func:`asyncio.run` function
14+
or the :class:`asyncio.Runner` with *loop_factory* to use
15+
the desired loop implementation.
16+
17+
1018
An event loop policy is a global object
1119
used to get and set the current :ref:`event loop <asyncio-event-loop>`,
1220
as well as create new event loops.

Doc/library/asyncio-runner.rst

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

7777
*coro* can be any awaitable object.
7878

79+
.. note::
80+
81+
The :mod:`!asyncio` policy system is deprecated and will be removed
82+
in Python 3.16; from there on, an explicit *loop_factory* is needed
83+
to configure the event loop.
84+
7985

8086
Runner context manager
8187
======================

Doc/library/socket.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,14 @@ Constants
674674

675675
.. availability:: Linux >= 3.9
676676

677+
.. data:: SO_REUSEPORT_LB
678+
679+
Constant to enable duplicate address and port bindings with load balancing.
680+
681+
.. versionadded:: next
682+
683+
.. availability:: FreeBSD >= 12.0
684+
677685
.. data:: AF_HYPERV
678686
HV_PROTOCOL_RAW
679687
HVSOCKET_CONNECT_TIMEOUT

Doc/whatsnew/3.14.rst

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,36 @@ Deprecated
691691
(Contributed by Serhiy Storchaka in :gh:`58032`.)
692692

693693
* :mod:`asyncio`:
694-
:func:`!asyncio.iscoroutinefunction` is deprecated
695-
and will be removed in Python 3.16,
696-
use :func:`inspect.iscoroutinefunction` instead.
697-
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
694+
695+
* :func:`!asyncio.iscoroutinefunction` is deprecated
696+
and will be removed in Python 3.16;
697+
use :func:`inspect.iscoroutinefunction` instead.
698+
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
699+
700+
* :mod:`asyncio` policy system is deprecated and will be removed in Python 3.16.
701+
In particular, the following classes and functions are deprecated:
702+
703+
* :class:`asyncio.AbstractEventLoopPolicy`
704+
* :class:`asyncio.DefaultEventLoopPolicy`
705+
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
706+
* :class:`asyncio.WindowsProactorEventLoopPolicy`
707+
* :func:`asyncio.get_event_loop_policy`
708+
* :func:`asyncio.set_event_loop_policy`
709+
* :func:`asyncio.set_event_loop`
710+
711+
Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
712+
*loop_factory* to use the desired event loop implementation.
713+
714+
For example, to use :class:`asyncio.SelectorEventLoop` on Windows::
715+
716+
import asyncio
717+
718+
async def main():
719+
...
720+
721+
asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)
722+
723+
(Contributed by Kumar Aditya in :gh:`127949`.)
698724

699725
* :mod:`builtins`:
700726
Passing a complex number as the *real* or *imag* argument in the

InternalDocs/frames.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Each activation record is laid out as:
3333
* Stack
3434

3535
This seems to provide the best performance without excessive complexity.
36-
The specials have a fixed size, so the offset of the locals is know. The
36+
The specials have a fixed size, so the offset of the locals is known. The
3737
interpreter needs to hold two pointers, a frame pointer and a stack pointer.
3838

3939
#### Alternative layout
@@ -52,7 +52,7 @@ an extra pointer for the locals, which can hurt performance.
5252
### Generators and Coroutines
5353

5454
Generators and coroutines contain a `_PyInterpreterFrame`
55-
The specials sections contains the following pointers:
55+
The specials section contains the following pointers:
5656

5757
* Globals dict
5858
* Builtins dict
@@ -69,7 +69,7 @@ and builtins, than strong references to both globals and builtins.
6969

7070
When creating a backtrace or when calling `sys._getframe()` the frame becomes
7171
visible to Python code. When this happens a new `PyFrameObject` is created
72-
and a strong reference to it placed in the `frame_obj` field of the specials
72+
and a strong reference to it is placed in the `frame_obj` field of the specials
7373
section. The `frame_obj` field is initially `NULL`.
7474

7575
The `PyFrameObject` may outlive a stack-allocated `_PyInterpreterFrame`.
@@ -128,7 +128,7 @@ The `return_offset` field determines where a `RETURN` should go in the caller,
128128
relative to `instr_ptr`. It is only meaningful to the callee, so it needs to
129129
be set in any instruction that implements a call (to a Python function),
130130
including CALL, SEND and BINARY_SUBSCR_GETITEM, among others. If there is no
131-
callee, then return_offset is meaningless. It is necessary to have a separate
131+
callee, then return_offset is meaningless. It is necessary to have a separate
132132
field for the return offset because (1) if we apply this offset to `instr_ptr`
133133
while executing the `RETURN`, this is too early and would lose us information
134134
about the previous instruction which we could need for introspecting and

Lib/asyncio/runners.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def run(main, *, debug=None, loop_factory=None):
177177
running in the same thread.
178178
179179
If debug is True, the event loop will be run in debug mode.
180+
If loop_factory is passed, it is used for new event loop creation.
180181
181182
This function always creates a new event loop and closes it at the end.
182183
It should be used as a main entry point for asyncio programs, and should

0 commit comments

Comments
 (0)