Skip to content

Commit b6ffca8

Browse files
committed
Comment
1 parent bc8134b commit b6ffca8

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
@@ -999,6 +999,9 @@ def tell(self):
999999
def peek(self, size=1):
10001000
if self.closed:
10011001
raise ValueError("peek on closed file")
1002+
# Due to slicing semantics, this works correctly
1003+
# even if the size is greater than the buffer length or
1004+
# the position is beyond the end of the buffer
10021005
if size < 1:
10031006
size = len(self._buffer) - self._pos
10041007
return self._buffer[self._pos : self._pos + size]

0 commit comments

Comments
 (0)