Skip to content

Commit b0f38fe

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Sync pre-release CPython main branch from GitHub (2026-07-30)
Summary: Imported python/cpython `3.16.0a0` from upstream rev [`f4b1d3e`](https://www.github.com/python/cpython/commit/f4b1d3e891d0d2055e53df3ccb84030bcaa148b5) (committed 2026-07-30 02:31:40+00:00). # Commit Info - Base: (`3.16.0a0`) - [`8b048eb`](https://www.github.com/python/cpython/commit/8b048eb35eb7f83dbff86dd11c7fdb37caab9e7a) (commit date: 2026-07-28 17:35:26+00:00) - Imported: (`3.16.0a0`) - [`f4b1d3e`](https://www.github.com/python/cpython/commit/f4b1d3e891d0d2055e53df3ccb84030bcaa148b5) (commit date: 2026-07-30 02:31:40+00:00) # Noteworthy file changes - Low-signal files (6 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GMOePScSBH_L3wMJAMbIL2Kl1ZY9br0LAAAz Differential Revision: D114171568 fbshipit-source-id: b11ad9cba0e9578dc8af307f6cd66220ae98ca45
1 parent 4e0084e commit b0f38fe

38 files changed

Lines changed: 686 additions & 201 deletions

Doc/library/asyncio-task.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ unless it is :exc:`asyncio.CancelledError`,
433433
is also included in the exception group.
434434
The same special case is made for
435435
:exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph.
436+
There is an additional special case made only for the body of the
437+
``async with``: if it raises :exc:`GeneratorExit` and none of the
438+
other tasks raise exceptions that would be reported, then the
439+
:exc:`GeneratorExit` is reraised.
436440

437441
Task groups are careful not to mix up the internal cancellation used to
438442
"wake up" their :meth:`~object.__aexit__` with cancellation requests
@@ -456,6 +460,10 @@ reported by :meth:`asyncio.Task.cancelling`.
456460
Improved handling of simultaneous internal and external cancellations
457461
and correct preservation of cancellation counts.
458462

463+
.. versionchanged:: 3.15
464+
465+
Addition of the special case for :exc:`GeneratorExit`.
466+
459467
Sleeping
460468
========
461469

Doc/library/multiprocessing.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,7 @@ with the :class:`Pool` class.
25362536
Callbacks should complete immediately since otherwise the thread which
25372537
handles the results will get blocked.
25382538

2539-
.. method:: imap(func, iterable[, chunksize])
2539+
.. method:: imap(func, iterable, chunksize=1, *, buffersize=None)
25402540

25412541
A lazier version of :meth:`.map`.
25422542

@@ -2550,12 +2550,27 @@ with the :class:`Pool` class.
25502550
``next(timeout)`` will raise :exc:`multiprocessing.TimeoutError` if the
25512551
result cannot be returned within *timeout* seconds.
25522552

2553-
.. method:: imap_unordered(func, iterable[, chunksize])
2553+
The *iterable* is collected immediately rather than lazily, unless a
2554+
*buffersize* is specified to limit the number of submitted tasks whose
2555+
results have not yet been yielded. If the buffer is full, iteration over
2556+
the *iterables* pauses until a result is yielded from the buffer.
2557+
To fully utilize pool's capacity when using this feature,
2558+
set *buffersize* at least to the number of processes in pool
2559+
(to consume *iterable* as you go), or even higher
2560+
(to prefetch the next ``N=buffersize-processes`` arguments).
2561+
2562+
.. versionchanged:: next
2563+
Added the *buffersize* parameter.
2564+
2565+
.. method:: imap_unordered(func, iterable, chunksize=1, *, buffersize=None)
25542566

25552567
The same as :meth:`imap` except that the ordering of the results from the
25562568
returned iterator should be considered arbitrary. (Only when there is
25572569
only one worker process is the order guaranteed to be "correct".)
25582570

2571+
.. versionchanged:: next
2572+
Added the *buffersize* parameter.
2573+
25592574
.. method:: starmap(func, iterable[, chunksize])
25602575

25612576
Like :meth:`~multiprocessing.pool.Pool.map` except that the

Doc/library/os.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,9 @@ process and user.
802802
Returns information identifying the current operating system.
803803
The return value is a :class:`uname_result`.
804804

805-
On macOS, iOS and Android, this returns the *kernel* name and version (i.e.,
805+
On macOS, iOS and Android, this returns the *kernel* name and release (i.e.,
806806
``'Darwin'`` on macOS and iOS; ``'Linux'`` on Android). :func:`platform.uname`
807-
can be used to get the user-facing operating system name and version on iOS and
807+
can be used to get the user-facing operating system name and release on iOS and
808808
Android.
809809

810810
.. seealso::

Doc/library/platform.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Cross platform
141141
Returns the system's release, e.g. ``'2.2.0'`` or ``'NT'``. An empty string is
142142
returned if the value cannot be determined.
143143

144+
On iOS and Android, this is the user-facing OS release. To obtain the
145+
Darwin or Linux kernel release, use :func:`os.uname`.
144146

145147
.. function:: system()
146148

@@ -163,9 +165,6 @@ Cross platform
163165
Returns the system's release version, e.g. ``'#3 on degas'``. An empty string is
164166
returned if the value cannot be determined.
165167

166-
On iOS and Android, this is the user-facing OS version. To obtain the
167-
Darwin or Linux kernel version, use :func:`os.uname`.
168-
169168
.. function:: uname()
170169

171170
Fairly portable uname interface. Returns a :func:`~collections.namedtuple`

Doc/whatsnew/3.16.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ math
376376
(Contributed by Jeff Epler in :gh:`150534`.)
377377

378378

379+
multiprocessing
380+
---------------
381+
382+
* Add the optional ``buffersize`` parameter to
383+
:meth:`multiprocessing.pool.Pool.imap` and
384+
:meth:`multiprocessing.pool.Pool.imap_unordered` to limit the number of
385+
submitted tasks whose results have not yet been yielded. If the buffer is
386+
full, iteration over the *iterables* pauses until a result is yielded from
387+
the buffer. To fully utilize pool's capacity when using this feature, set
388+
*buffersize* at least to the number of processes in pool (to consume
389+
*iterable* as you go), or even higher (to prefetch the next
390+
``N=buffersize-processes`` arguments).
391+
392+
(Contributed by Oleksandr Baltian in :gh:`136871`.)
393+
394+
379395
os
380396
--
381397

@@ -606,7 +622,7 @@ module_name
606622

607623

608624
Removed
609-
=======
625+
========
610626

611627
annotationlib
612628
-------------

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/asyncio/taskgroups.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,23 @@ async def _aexit(self, et, exc):
174174
self._parent_task.uncancel()
175175
self._parent_task.cancel()
176176
try:
177-
raise BaseExceptionGroup(
178-
'unhandled errors in a TaskGroup',
179-
self._errors,
180-
) from None
177+
# If the *only* error is a GeneratorExit from the body
178+
# of the group, then instead of raising an
179+
# ExceptionGroup we raise GeneratorExit. This ensures
180+
# that async generators that use TaskGroup properly
181+
# swallow the exception on `aclose()` while ensuring
182+
# that no exceptions from subtasks are swallowed.
183+
if (
184+
et is not None
185+
and issubclass(et, GeneratorExit)
186+
and len(self._errors) == 1
187+
):
188+
raise exc
189+
else:
190+
raise BaseExceptionGroup(
191+
'unhandled errors in a TaskGroup',
192+
self._errors,
193+
) from None
181194
finally:
182195
exc = None
183196

Lib/ctypes/util.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -412,53 +412,12 @@ def find_library(name):
412412
_get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
413413

414414

415-
# Listing loaded libraries on other systems will try to use
416-
# functions common to Linux and a few other Unix-like systems.
417-
# See the following for several platforms' documentation of the same API:
418-
# https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
419-
# https://man.freebsd.org/cgi/man.cgi?query=dl_iterate_phdr
420-
# https://man.openbsd.org/dl_iterate_phdr
421-
# https://docs.oracle.com/cd/E88353_01/html/E37843/dl-iterate-phdr-3c.html
422-
if (os.name == "posix" and
423-
sys.platform not in {"darwin", "ios", "tvos", "watchos"}):
424-
import ctypes
425-
if hasattr((_libc := ctypes.CDLL(None)), "dl_iterate_phdr"):
426-
427-
class _dl_phdr_info(ctypes.Structure):
428-
_fields_ = [
429-
("dlpi_addr", ctypes.c_void_p),
430-
("dlpi_name", ctypes.c_char_p),
431-
("dlpi_phdr", ctypes.c_void_p),
432-
("dlpi_phnum", ctypes.c_ushort),
433-
]
434-
435-
_dl_phdr_callback = ctypes.CFUNCTYPE(
436-
ctypes.c_int,
437-
ctypes.POINTER(_dl_phdr_info),
438-
ctypes.c_size_t,
439-
ctypes.POINTER(ctypes.py_object),
440-
)
441-
442-
@_dl_phdr_callback
443-
def _info_callback(info, _size, data):
444-
libraries = data.contents.value
445-
name = os.fsdecode(info.contents.dlpi_name)
446-
libraries.append(name)
447-
return 0
448-
449-
_dl_iterate_phdr = _libc["dl_iterate_phdr"]
450-
_dl_iterate_phdr.argtypes = [
451-
_dl_phdr_callback,
452-
ctypes.POINTER(ctypes.py_object),
453-
]
454-
_dl_iterate_phdr.restype = ctypes.c_int
455-
456-
def dllist():
457-
"""Return a list of loaded shared libraries in the current process."""
458-
libraries = []
459-
_dl_iterate_phdr(_info_callback,
460-
ctypes.byref(ctypes.py_object(libraries)))
461-
return libraries
415+
# On platforms which provide dl_iterate_phdr(), dllist() is implemented
416+
# in _ctypes.
417+
try:
418+
from _ctypes import dllist
419+
except ImportError:
420+
pass
462421

463422

464423
@dataclass(slots=True, frozen=True)

0 commit comments

Comments
 (0)