Skip to content

Commit fd85b46

Browse files
committed
Document BufferedReader.peek and BytesIO.peek similarly
1 parent 4855189 commit fd85b46

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Doc/library/io.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,10 @@ than raw I/O does.
731731
.. method:: peek(size=1, /)
732732

733733
Return bytes from the current position onwards without advancing the position.
734+
At least one byte of data is returned if not at EOF.
735+
Return an empty :class:`bytes` object at EOF.
734736
If the size argument is less than one or larger than the number of available bytes,
735737
a copy of the buffer from the current position until the end is returned.
736-
Return an empty bytes object at EOF.
737738

738739
.. versionadded:: 3.13
739740

@@ -769,9 +770,12 @@ than raw I/O does.
769770

770771
.. method:: peek(size=0, /)
771772

772-
Return bytes from the stream without advancing the position. At most one
773-
single read on the raw stream is done to satisfy the call. The number of
774-
bytes returned may be less or more than requested.
773+
Return bytes from the current position onwards without advancing the position.
774+
At least one byte of data is returned if not at EOF.
775+
Return an empty :class:`bytes` object at EOF.
776+
At most one single read on the underlying raw stream is done to satisfy the call.
777+
The exact number of bytes returned is unspecified
778+
(*size* is ignored).
775779

776780
.. method:: read(size=-1, /)
777781

0 commit comments

Comments
 (0)