summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorJan Gosmann <jan@hyper-world.de>2023-02-17 21:01:26 (GMT)
committerGitHub <noreply@github.com>2023-02-17 21:01:26 (GMT)
commit77d95c83733722ada35eb1ef89ae5b84a51ddd32 (patch)
treecebdc99dc1ef2fe0d59e967b12f7cd183e18c582 /Lib/asyncio
parenta1723caabfcdca5d675c4cb04554fb04c7edf601 (diff)
downloadcpython-77d95c83733722ada35eb1ef89ae5b84a51ddd32.zip
cpython-77d95c83733722ada35eb1ef89ae5b84a51ddd32.tar.gz
cpython-77d95c83733722ada35eb1ef89ae5b84a51ddd32.tar.bz2
gh-100226: Clarify StreamReader.read behavior (#101807)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/streams.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 7d13e96..bf15f51 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -649,16 +649,17 @@ class StreamReader:
async def read(self, n=-1):
"""Read up to `n` bytes from the stream.
- If n is not provided, or set to -1, read until EOF and return all read
- bytes. If the EOF was received and the internal buffer is empty, return
- an empty bytes object.
+ If `n` is not provided or set to -1,
+ read until EOF, then return all read bytes.
+ If EOF was received and the internal buffer is empty,
+ return an empty bytes object.
- If n is zero, return empty bytes object immediately.
+ If `n` is 0, return an empty bytes object immediately.
- If n is positive, this function try to read `n` bytes, and may return
- less or equal bytes than requested, but at least one byte. If EOF was
- received before any byte is read, this function returns empty byte
- object.
+ If `n` is positive, return at most `n` available bytes
+ as soon as at least 1 byte is available in the internal buffer.
+ If EOF is received before any byte is read, return an empty
+ bytes object.
Returned value is not limited with limit, configured at stream
creation.