Skip to content

Commit 5733d5a

Browse files
committed
Comment
1 parent fd85b46 commit 5733d5a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Lib/_pyio.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,9 @@ def tell(self):
981981
def peek(self, size=1):
982982
if self.closed:
983983
raise ValueError("peek on closed file")
984+
# Due to slicing semantics, this works correctly
985+
# even if the size is greater than the buffer length or
986+
# the position is beyond the end of the buffer
984987
if size < 1:
985988
size = len(self._buffer) - self._pos
986989
return self._buffer[self._pos : self._pos + size]

0 commit comments

Comments
 (0)