Skip to content

Commit 11e65fe

Browse files
authored
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 5105c55 commit 11e65fe

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

Doc/library/io.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,11 @@ than raw I/O does.
773773

774774
.. method:: peek(size=0, /)
775775

776-
Return a copy of the buffer from the current position onwards without advancing the position.
776+
Return a copy of the buffer from the current position onwards without
777+
advancing the position.
777778

778-
If *size* is less than one or omitted, at most `DEFAULT_BUFFER_SIZE` bytes are returned.
779+
If *size* is less than one or omitted, at most
780+
:data:`DEFAULT_BUFFER_SIZE` bytes are returned.
779781
Otherwise, at most *size* bytes are returned.
780782
Return an empty :class:`bytes` object at EOF.
781783

Doc/whatsnew/3.16.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ gzip
9696
io
9797
--
9898

99-
* Add :meth:`io.BytesIO.peek`.
99+
* Add :meth:`io.BytesIO.peek` method to read without advancing position.
100100
(Contributed by Marcel Martin in :gh:`90533`.)
101101

102102
lzma

Lib/test/test_io/test_memoryio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ def test_peek(self):
619619
self.assertEqual(memio.peek(), buf[:io.DEFAULT_BUFFER_SIZE])
620620
self.assertEqual(memio.peek(0), buf[:io.DEFAULT_BUFFER_SIZE])
621621
self.assertEqual(memio.peek(-1), buf[:io.DEFAULT_BUFFER_SIZE])
622-
self.assertEqual(memio.peek(io.DEFAULT_BUFFER_SIZE + 100), buf[:io.DEFAULT_BUFFER_SIZE + 100])
622+
self.assertEqual(memio.peek(io.DEFAULT_BUFFER_SIZE + 100),
623+
buf[:io.DEFAULT_BUFFER_SIZE + 100])
623624
self.assertEqual(memio.peek(io.DEFAULT_BUFFER_SIZE * 100), buf)
624625

625626
# Current position beyond buffer end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add :meth:`io.BytesIO.peek`.
1+
Add :meth:`io.BytesIO.peek` method to read without advancing position.

0 commit comments

Comments
 (0)