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 1d793e3 commit 9b0b04fCopy full SHA for 9b0b04f
Lib/_pyio.py
@@ -981,12 +981,9 @@ def tell(self):
981
def peek(self, size=1):
982
if self.closed:
983
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
987
if size < 0:
988
- size = len(self._buffer) - self._pos
989
- return self._buffer[self._pos : self._pos + size]
+ return self._buffer[self._pos:]
+ return self._buffer[self._pos:self._pos + size]
990
991
def truncate(self, pos=None):
992
0 commit comments