diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-06-08 03:06:48 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-06-08 03:06:48 (GMT) |
commit | 10e847bbc7427e85f38191298275eaf14be625e5 (patch) | |
tree | be494f64eebfc2fdc0be613ddd0d73b2fe0033d0 /Doc/library | |
parent | 66f80e92c31cdcede9951d661b3538d862f632b1 (diff) | |
download | cpython-10e847bbc7427e85f38191298275eaf14be625e5.zip cpython-10e847bbc7427e85f38191298275eaf14be625e5.tar.gz cpython-10e847bbc7427e85f38191298275eaf14be625e5.tar.bz2 |
add BufferedIOBase.readinto1 (closes #20578)
Patch by Nikolaus Rath.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/io.rst | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 79f65e0..3a9872a 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -385,8 +385,8 @@ I/O Base Classes .. method:: readinto(b) Read up to ``len(b)`` bytes into :class:`bytearray` *b* and return the - number of bytes read. If the object is in non-blocking mode and no - bytes are available, ``None`` is returned. + number of bytes read. If the object is in non-blocking mode and no bytes + are available, ``None`` is returned. .. method:: write(b) @@ -459,10 +459,11 @@ I/O Base Classes .. method:: read1(size=-1) - Read and return up to *size* bytes, with at most one call to the underlying - raw stream's :meth:`~RawIOBase.read` method. This can be useful if you - are implementing your own buffering on top of a :class:`BufferedIOBase` - object. + Read and return up to *size* bytes, with at most one call to the + underlying raw stream's :meth:`~RawIOBase.read` (or + :meth:`~RawIOBase.readinto`) method. This can be useful if you + are implementing your own buffering on top of a + :class:`BufferedIOBase` object. .. method:: readinto(b) @@ -472,8 +473,19 @@ I/O Base Classes Like :meth:`read`, multiple reads may be issued to the underlying raw stream, unless the latter is interactive. + A :exc:`BlockingIOError` is raised if the underlying raw stream is in non + blocking-mode, and has no data available at the moment. + + .. method:: readinto1(b) + + Read up to ``len(b)`` bytes into bytearray *b*, using at most one call to + the underlying raw stream's :meth:`~RawIOBase.read` (or + :meth:`~RawIOBase.readinto`) method. Return the number of bytes read. + A :exc:`BlockingIOError` is raised if the underlying raw stream is in - non blocking-mode, and has no data available at the moment. + non-blocking mode and has no data available at the moment. + + .. versionadded:: 3.5 .. method:: write(b) @@ -590,6 +602,11 @@ than raw I/O does. In :class:`BytesIO`, this is the same as :meth:`read`. + .. method:: readinto1() + + In :class:`BytesIO`, this is the same as :meth:`readinto`. + + .. versionadded:: 3.5 .. class:: BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE) |