We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc8134b commit b6ffca8Copy full SHA for b6ffca8
Lib/_pyio.py
@@ -999,6 +999,9 @@ def tell(self):
999
def peek(self, size=1):
1000
if self.closed:
1001
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
1005
if size < 1:
1006
size = len(self._buffer) - self._pos
1007
return self._buffer[self._pos : self._pos + size]
0 commit comments