File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed
Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -65,11 +65,10 @@ In-memory text streams are also available as :class:`StringIO` objects::
6565 f = io.StringIO("some initial text data")
6666
6767.. note ::
68- If you are working with a non-blocking stream, be aware that operations on text I/O
69- objects may raise a ``BlockingIOError ``. This occurs when the underlying stream is
70- in non-blocking mode and a read operation cannot be completed immediately, potentially
71- leading to a ``BlockingIOError ``. To handle this, ensure your code properly catches and
72- manages such exceptions when working with non-blocking streams.
68+ When working with a non-blocking stream, be aware that operations on text I/O objects
69+ might raise a :exc: `BlockingIOError ` if the stream cannot perform a read operation
70+ immediately.
71+
7372
7473The text stream API is described in detail in the documentation of
7574:class: `TextIOBase `.
@@ -778,9 +777,8 @@ than raw I/O does.
778777 EOF or if the read call would block in non-blocking mode.
779778
780779 .. note ::
781- When the underlying raw stream is non-blocking, a ``BlockingIOError ``
782- may be raised if the read operation cannot be completed immediately.
783- Ensure proper exception handling in such cases.
780+ When the underlying raw stream is non-blocking, a :exc: `BlockingIOError `
781+ may be raised if a read operation cannot be completed immediately.
784782
785783 .. method :: read1(size=-1, /)
786784
Original file line number Diff line number Diff line change @@ -2524,13 +2524,13 @@ def read(self, size=None):
25242524 decoder = self ._decoder or self ._get_decoder ()
25252525 if size < 0 :
25262526
2527- b = self .buffer .read ()
2528- if b is None :
2527+ chunk = self .buffer .read ()
2528+ if chunk is None :
25292529 raise BlockingIOError
25302530
25312531 # Read everything.
25322532 result = (self ._get_decoded_chars () +
2533- decoder .decode (b , final = True ))
2533+ decoder .decode (chunk , final = True ))
25342534 if self ._snapshot is not None :
25352535 self ._set_decoded_chars ('' )
25362536 self ._snapshot = None
Original file line number Diff line number Diff line change @@ -1994,9 +1994,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
19941994
19951995 if (bytes == Py_None ){
19961996 PyErr_SetString (PyExc_BlockingIOError , "Unexpected None encountered. This may be due to non-blocking I/O "
1997- "or an issue with the underlying I/O implementation. Please refer to "
1998- "the documentation or ensure that the I/O operation is properly "
1999- "configured." );
1997+ "or an issue with the underlying I/O implementation." );
20001998 return NULL ;
20011999
20022000 }
You can’t perform that action at this time.
0 commit comments