Skip to content

Commit 157dd29

Browse files
ambvmeta-codesync[bot]
authored andcommitted
Sync pre-release CPython main branch from GitHub (2026-07-15)
Summary: Imported python/cpython `3.16.0a0` from upstream rev [`87411d0`](https://www.github.com/python/cpython/commit/87411d0742f070b1424c08b41cf3af49d377b215) (committed 2026-07-15 03:06:24+00:00). # Commit Info - Base: (`3.16.0a0`) - [`2dc1a91`](https://www.github.com/python/cpython/commit/2dc1a91af801ea896e21f6c6e6cc41f57e8268d9) (commit date: 2026-07-13 22:38:43+00:00) - Imported: (`3.16.0a0`) - [`87411d0`](https://www.github.com/python/cpython/commit/87411d0742f070b1424c08b41cf3af49d377b215) (commit date: 2026-07-15 03:06:24+00:00) # Noteworthy file changes - Low-signal files (7 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GNxi1SErxX7n1ZMFAOn3_Fu84codbr0LAAAz Reviewed By: itamaro, alexmalyshev Differential Revision: D112059877 fbshipit-source-id: dbd06cdecbf2bb48ec45e824b394daeca652c14a
1 parent b0bd781 commit 157dd29

52 files changed

Lines changed: 1033 additions & 174 deletions

Some content is hidden

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

.github/workflows/reusable-emscripten.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ jobs:
7777
run: python3 Platforms/emscripten pythoninfo-host
7878
- name: "Test"
7979
run: python3 Platforms/emscripten run --test
80+
- name: "Test Repl"
81+
run: Platforms/emscripten/browser_test/run_test.sh

Doc/library/asyncio-eventloop.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,9 @@ Working with pipes
12631263
*protocol_factory* must be a callable returning an
12641264
:ref:`asyncio protocol <asyncio-protocol>` implementation.
12651265

1266-
*pipe* is a :term:`file-like object <file object>`.
1266+
*pipe* is a :term:`file-like object <file object>`. See
1267+
:ref:`Supported pipe objects <asyncio-pipe-objects>` for the objects
1268+
supported as *pipe*.
12671269

12681270
Return pair ``(transport, protocol)``, where *transport* supports
12691271
the :class:`ReadTransport` interface and *protocol* is an object
@@ -1280,7 +1282,9 @@ Working with pipes
12801282
*protocol_factory* must be a callable returning an
12811283
:ref:`asyncio protocol <asyncio-protocol>` implementation.
12821284

1283-
*pipe* is :term:`file-like object <file object>`.
1285+
*pipe* is a :term:`file-like object <file object>`. See
1286+
:ref:`Supported pipe objects <asyncio-pipe-objects>` for the objects
1287+
supported as *pipe*.
12841288

12851289
Return pair ``(transport, protocol)``, where *transport* supports
12861290
:class:`WriteTransport` interface and *protocol* is an object
@@ -1289,6 +1293,33 @@ Working with pipes
12891293
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
12901294
non-blocking mode.
12911295

1296+
.. _asyncio-pipe-objects:
1297+
1298+
.. rubric:: Supported pipe objects
1299+
1300+
These methods only work with objects the operating system can poll for
1301+
readiness or perform overlapped I/O on. Regular files on disk are **not**
1302+
supported on any platform. There is no asynchronous file I/O in asyncio;
1303+
use :meth:`loop.run_in_executor` to read and write regular files without
1304+
blocking the event loop.
1305+
1306+
On Unix, with :class:`SelectorEventLoop`, *pipe* must wrap one of the
1307+
following:
1308+
1309+
* a pipe, such as an end of an :func:`os.pipe` pair or a FIFO created with
1310+
:func:`os.mkfifo`;
1311+
* a socket;
1312+
* a character device, such as a terminal.
1313+
1314+
On Windows, where only :class:`ProactorEventLoop` implements these methods,
1315+
*pipe* must wrap a handle opened for overlapped I/O (that is, created with the
1316+
``FILE_FLAG_OVERLAPPED`` flag), since the handle has to be associated with an
1317+
I/O completion port. Handles that were not opened for overlapped I/O are
1318+
rejected. In particular, the standard streams (:data:`sys.stdin`,
1319+
:data:`sys.stdout` and :data:`sys.stderr`), console handles, and the pipes
1320+
created by :func:`os.pipe` are **not** opened for overlapped I/O and therefore
1321+
cannot be used with these methods.
1322+
12921323
.. note::
12931324

12941325
:class:`SelectorEventLoop` does not support the above methods on

Doc/library/asyncio-platforms.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ All Platforms
1919
* :meth:`loop.add_reader` and :meth:`loop.add_writer`
2020
cannot be used to monitor file I/O.
2121

22+
* :meth:`loop.connect_read_pipe` and :meth:`loop.connect_write_pipe`
23+
cannot be used with regular files. See :ref:`Supported pipe objects
24+
<asyncio-pipe-objects>` for the objects that are accepted on each
25+
platform.
26+
2227

2328
Windows
2429
=======
@@ -62,6 +67,10 @@ All event loops on Windows do not support the following methods:
6267
* The :meth:`loop.add_reader` and :meth:`loop.add_writer`
6368
methods are not supported.
6469

70+
* :meth:`loop.connect_read_pipe` and :meth:`loop.connect_write_pipe` only
71+
accept a handle opened for overlapped I/O.
72+
See :ref:`Supported pipe objects <asyncio-pipe-objects>` for which objects are supported.
73+
6574
The resolution of the monotonic clock on Windows is usually around 15.6
6675
milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on the
6776
hardware (availability of `HPET

Doc/library/struct.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The module defines the following exception and functions:
6868
Pack the values *v1*, *v2*, ... according to the format string *format* and
6969
write the packed bytes into the writable buffer *buffer* starting at
7070
position *offset*. Note that *offset* is a required argument.
71+
A negative *offset* counts from the end of *buffer*.
7172

7273

7374
.. function:: unpack(format, buffer)
@@ -84,6 +85,7 @@ The module defines the following exception and functions:
8485
string *format*. The result is a tuple even if it contains exactly one
8586
item. The buffer's size in bytes, starting at position *offset*, must be at
8687
least the size required by the format, as reflected by :func:`calcsize`.
88+
A negative *offset* counts from the end of *buffer*.
8789

8890

8991
.. function:: iter_unpack(format, buffer)

Doc/library/weakref.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ exposed by the :mod:`!weakref` module for the benefit of advanced uses.
6363
Not all objects can be weakly referenced. Objects which support weak references
6464
include class instances, functions written in Python (but not in C), instance methods,
6565
sets, frozensets, some :term:`file objects <file object>`, :term:`generators <generator>`,
66-
type objects, sockets, arrays, deques, regular expression pattern objects, and code
67-
objects.
66+
type objects, sockets, arrays, deques, regular expression pattern objects, code
67+
objects, and frame objects.
6868

6969
.. versionchanged:: 3.2
7070
Added support for thread.lock, threading.Lock, and code objects.
7171

72+
.. versionchanged:: 3.16
73+
Added support for frame objects.
74+
7275
Several built-in types such as :class:`list` and :class:`dict` do not directly
7376
support weak references but can add support through subclassing::
7477

Doc/using/windows.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ omitted in cases where the tag refers to an official release and starts with
162162
$> py -V:3-arm64 ...
163163
164164
Runtimes from other distributors may require the *company* to be included as
165-
well. This should be separated from the tag by a slash, and may be a prefix.
165+
well.
166+
It should be separated from the tag by a slash (either ``/`` or ``\``),
167+
and may be shortened to any prefix of its full value.
166168
Specifying the company is optional when it is ``PythonCore``, and specifying the
167169
tag is optional (but not the slash) when you want the latest release from a
168170
specific company.

Doc/whatsnew/3.16.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ New features
7575
Other language changes
7676
======================
7777

78+
* :ref:`Frame objects <frame-objects>` now support :mod:`weak references
79+
<weakref>`. This allows associating extra data with active frames,
80+
for example in debuggers, without keeping the frames (and everything
81+
they reference) alive indefinitely.
82+
(Contributed by Łukasz Langa in :gh:`102960`.)
7883

7984

8085
New modules
@@ -263,8 +268,9 @@ imaplib
263268
(Contributed by Przemysław Buczkowski and Serhiy Storchaka in :gh:`89869`.)
264269

265270
* Non-ASCII mailbox names are now automatically encoded as modified UTF-7
266-
(:rfc:`3501`, section 5.1.3), so international mailbox names can be passed
267-
as ordinary :class:`str`.
271+
(:rfc:`3501`, section 5.1.3) in the default mode, so international mailbox
272+
names can be passed as ordinary :class:`str` without enabling ``UTF8=ACCEPT``
273+
(under which they are sent as UTF-8).
268274
(Contributed by Serhiy Storchaka in :gh:`49555`.)
269275

270276
* The :meth:`~imaplib.IMAP4.copy`, :meth:`~imaplib.IMAP4.move`,

Include/internal/pycore_fileutils_windows.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static inline BOOL _Py_GetFileInformationByName(
5555
static int GetFileInformationByName_init = -1;
5656

5757
if (GetFileInformationByName_init < 0) {
58+
#ifdef MS_WINDOWS_DESKTOP
5859
HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4");
60+
#else
61+
HMODULE hMod = LoadPackagedLibrary(L"api-ms-win-core-file-l2-1-4", 0);
62+
#endif
5963
GetFileInformationByName_init = 0;
6064
if (hMod) {
6165
GetFileInformationByName = (PGetFileInformationByName)GetProcAddress(

Include/internal/pycore_frame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct _frame {
3434
* "support" for the borrowed references, ensuring that they remain valid.
3535
*/
3636
PyObject *f_overwritten_fast_locals;
37+
PyObject *f_weakreflist; /* List of weak references */
3738
/* The frame data, if this frame object owns the frame */
3839
PyObject *_f_frame_data[1];
3940
};

Lib/asyncio/proactor_events.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(self, loop, sock, protocol, waiter=None,
6262
self._closing = False # Set when close() called.
6363
self._called_connection_lost = False
6464
self._eof_written = False
65+
self._empty_waiter = None
6566
if self._server is not None:
6667
self._server._attach(self)
6768
self._loop.call_soon(self._protocol.connection_made, self)
@@ -331,10 +332,6 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport,
331332

332333
_start_tls_compatible = True
333334

334-
def __init__(self, *args, **kw):
335-
super().__init__(*args, **kw)
336-
self._empty_waiter = None
337-
338335
def write(self, data):
339336
if not isinstance(data, (bytes, bytearray, memoryview)):
340337
raise TypeError(
@@ -465,7 +462,6 @@ class _ProactorDatagramTransport(_ProactorBasePipeTransport,
465462
def __init__(self, loop, sock, protocol, address=None,
466463
waiter=None, extra=None):
467464
self._address = address
468-
self._empty_waiter = None
469465
self._buffer_size = 0
470466
# We don't need to call _protocol.connection_made() since our base
471467
# constructor does it for us.

0 commit comments

Comments
 (0)