mirror of
https://github.com/python/cpython.git
synced 2025-08-26 11:45:20 +00:00
gh-109523: Raise a BlockingIOError if reading text from a non-blocking stream cannot immediately return bytes. (GH-122933)
This commit is contained in:
parent
930ba0ce60
commit
31f16e427b
7 changed files with 57 additions and 1 deletions
|
@ -2545,9 +2545,12 @@ class TextIOWrapper(TextIOBase):
|
|||
size = size_index()
|
||||
decoder = self._decoder or self._get_decoder()
|
||||
if size < 0:
|
||||
chunk = self.buffer.read()
|
||||
if chunk is None:
|
||||
raise BlockingIOError("Read returned None.")
|
||||
# Read everything.
|
||||
result = (self._get_decoded_chars() +
|
||||
decoder.decode(self.buffer.read(), final=True))
|
||||
decoder.decode(chunk, final=True))
|
||||
if self._snapshot is not None:
|
||||
self._set_decoded_chars('')
|
||||
self._snapshot = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue