Skip to content

Commit 9b0b04f

Browse files
committed
Simplify
1 parent 1d793e3 commit 9b0b04f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Lib/_pyio.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,9 @@ def tell(self):
981981
def peek(self, size=1):
982982
if self.closed:
983983
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
987984
if size < 0:
988-
size = len(self._buffer) - self._pos
989-
return self._buffer[self._pos : self._pos + size]
985+
return self._buffer[self._pos:]
986+
return self._buffer[self._pos:self._pos + size]
990987

991988
def truncate(self, pos=None):
992989
if self.closed:

0 commit comments

Comments
 (0)