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 4126a64 commit 1ea40c2Copy full SHA for 1ea40c2
Lib/_pyio.py
@@ -999,12 +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 < 0:
1006
- size = len(self._buffer) - self._pos
1007
- return self._buffer[self._pos : self._pos + size]
+ return self._buffer[self._pos:]
+ return self._buffer[self._pos:self._pos + size]
1008
1009
def truncate(self, pos=None):
1010
0 commit comments