diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-02-23 13:35:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 13:35:59 (GMT) |
commit | 42d0ca92ed141e7518b5b4d77e6e27e36ac451dc (patch) | |
tree | 5cac48f8589570c1dc09eaad110e730215c4f23f /Lib/asyncio/streams.py | |
parent | bf0a8362cdc2670373b4462943e6e6bf156d0a5c (diff) | |
download | cpython-42d0ca92ed141e7518b5b4d77e6e27e36ac451dc.zip cpython-42d0ca92ed141e7518b5b4d77e6e27e36ac451dc.tar.gz cpython-42d0ca92ed141e7518b5b4d77e6e27e36ac451dc.tar.bz2 |
[3.11] gh-100226: Clarify StreamReader.read behavior (GH-101807) (#102001)
gh-100226: Clarify StreamReader.read behavior (GH-101807)
(cherry picked from commit 77d95c83733722ada35eb1ef89ae5b84a51ddd32)
Co-authored-by: Jan Gosmann <jan@hyper-world.de>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r-- | Lib/asyncio/streams.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index d21a31d..560ad8a 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -648,16 +648,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. |