Support sizehint in _fileobject.readlines, as documented.

This commit is contained in:
Martin v. Löwis 2000-09-19 11:25:58 +00:00
parent 543f2438ba
commit 6df27f8d1c
1 changed files with 5 additions and 1 deletions

View File

@ -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