Skip to content

Commit c5f3df0

Browse files
committed
Add Whats New, os.rst, tweak NEWS
1 parent 4da3fec commit c5f3df0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Doc/library/os.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,28 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16591659
:exc:`InterruptedError` exception (see :pep:`475` for the rationale).
16601660

16611661

1662+
.. function:: readinto(fd, buffer, /)
1663+
1664+
Read from a file descriptor *fd* into a mutable
1665+
:ref:`buffer protocol <bufferobjects>` *buffer*.
1666+
1667+
The *buffer* should be mutable and :term:`bytes-like
1668+
objects <bytes-like object>`. On success, returns the number of
1669+
bytes read. Less bytes may be read than the size of the buffer. Will retry the
1670+
underlying system call when interrupted by a signal. For other errors, the
1671+
system call will not be retried.
1672+
1673+
.. note::
1674+
1675+
This function is intended for low-level I/O and must be applied to a file
1676+
descriptor as returned by :func:`os.open` or :func:`pipe`. To read a
1677+
"file object" returned by the built-in function :func:`open` or by
1678+
:func:`popen` or :func:`fdopen`, or :data:`sys.stdin`, use its
1679+
:meth:`~file.readinto` or :meth:`~file.read`.
1680+
1681+
.. versionadded:: 3.14
1682+
1683+
16621684
.. function:: sendfile(out_fd, in_fd, offset, count)
16631685
sendfile(out_fd, in_fd, offset, count, headers=(), trailers=(), flags=0)
16641686

Doc/whatsnew/3.14.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ os
561561
to the :mod:`os` module.
562562
(Contributed by James Roy in :gh:`127688`.)
563563

564+
* Add the :func:`os.readinto` function to read into a
565+
:ref:`buffer protocol <bufferobjects>` from a file descriptor.
566+
(Contributed by Cody Maloney in :gh:`129205`.)
564567

565568
pathlib
566569
-------
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add ``os.readinto`` to read into a :ref:`buffer protocol <bufferobjects>` from a file descriptor.
1+
Add :func:`os.readinto` to read into a :ref:`buffer protocol <bufferobjects>` from a file descriptor.

0 commit comments

Comments
 (0)