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 fd85b46 commit 5733d5aCopy full SHA for 5733d5a
Lib/_pyio.py
@@ -981,6 +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 < 1:
988
size = len(self._buffer) - self._pos
989
return self._buffer[self._pos : self._pos + size]
0 commit comments