Skip to content

Commit 1ea40c2

Browse files
committed
Simplify
1 parent 4126a64 commit 1ea40c2

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
@@ -999,12 +999,9 @@ def tell(self):
999999
def peek(self, size=1):
10001000
if self.closed:
10011001
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
10051002
if size < 0:
1006-
size = len(self._buffer) - self._pos
1007-
return self._buffer[self._pos : self._pos + size]
1003+
return self._buffer[self._pos:]
1004+
return self._buffer[self._pos:self._pos + size]
10081005

10091006
def truncate(self, pos=None):
10101007
if self.closed:

0 commit comments

Comments
 (0)