summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGiovanni Siragusa <siracusano@gmail.com>2024-12-02 13:18:30 (GMT)
committerGitHub <noreply@github.com>2024-12-02 13:18:30 (GMT)
commit31f16e427b545f66a9a45ea9dd6c933975ce0e4c (patch)
treeb474deff7609570a193b6232a2992dc03701af59 /Doc/library
parent930ba0ce605eee9e3b992fa368b00a3f2b7dc4c1 (diff)
downloadcpython-31f16e427b545f66a9a45ea9dd6c933975ce0e4c.zip
cpython-31f16e427b545f66a9a45ea9dd6c933975ce0e4c.tar.gz
cpython-31f16e427b545f66a9a45ea9dd6c933975ce0e4c.tar.bz2
gh-109523: Raise a BlockingIOError if reading text from a non-blocking stream cannot immediately return bytes. (GH-122933)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/io.rst20
1 files changed, 20 insertions, 0 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index f793d7a..0d8cc51 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -64,6 +64,12 @@ In-memory text streams are also available as :class:`StringIO` objects::
f = io.StringIO("some initial text data")
+.. note::
+
+ When working with a non-blocking stream, be aware that read operations on text I/O objects
+ might raise a :exc:`BlockingIOError` if the stream cannot perform the operation
+ immediately.
+
The text stream API is described in detail in the documentation of
:class:`TextIOBase`.
@@ -770,6 +776,11 @@ than raw I/O does.
Read and return *size* bytes, or if *size* is not given or negative, until
EOF or if the read call would block in non-blocking mode.
+ .. note::
+
+ When the underlying raw stream is non-blocking, a :exc:`BlockingIOError`
+ may be raised if a read operation cannot be completed immediately.
+
.. method:: read1(size=-1, /)
Read and return up to *size* bytes with only one call on the raw stream.
@@ -779,6 +790,10 @@ than raw I/O does.
.. versionchanged:: 3.7
The *size* argument is now optional.
+ .. note::
+
+ When the underlying raw stream is non-blocking, a :exc:`BlockingIOError`
+ may be raised if a read operation cannot be completed immediately.
.. class:: BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)
@@ -1007,6 +1022,11 @@ Text I/O
.. versionchanged:: 3.10
The *encoding* argument now supports the ``"locale"`` dummy encoding name.
+ .. note::
+
+ When the underlying raw stream is non-blocking, a :exc:`BlockingIOError`
+ may be raised if a read operation cannot be completed immediately.
+
:class:`TextIOWrapper` provides these data attributes and methods in
addition to those from :class:`TextIOBase` and :class:`IOBase`: