Support sizehint in _fileobject.readlines, as documented.
This commit is contained in:
parent
543f2438ba
commit
6df27f8d1c
|
@ -228,10 +228,14 @@ class _fileobject:
|
||||||
data, self._rbuf = self._rbuf[:i], self._rbuf[i:]
|
data, self._rbuf = self._rbuf[:i], self._rbuf[i:]
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def readlines(self):
|
def readlines(self, sizehint = 0):
|
||||||
|
total = 0
|
||||||
list = []
|
list = []
|
||||||
while 1:
|
while 1:
|
||||||
line = self.readline()
|
line = self.readline()
|
||||||
if not line: break
|
if not line: break
|
||||||
list.append(line)
|
list.append(line)
|
||||||
|
total += len(line)
|
||||||
|
if sizehint and total >= sizehint:
|
||||||
|
break
|
||||||
return list
|
return list
|
||||||
|
|
Loading…
Reference in New Issue