Support sizehint in StringIO.readlines, as documented.

This commit is contained in:
Martin v. Löwis 2000-09-19 11:07:44 +00:00
parent c912a3a8fd
commit a05fa1d9d4
1 changed files with 5 additions and 1 deletions

View File

@ -91,11 +91,15 @@ class StringIO:
r = self.buf[self.pos:newpos]
self.pos = newpos
return r
def readlines(self):
def readlines(self, sizehint = 0):
total = 0
lines = []
line = self.readline()
while line:
lines.append(line)
total += len(line)
if 0 < sizehint <= total:
break
line = self.readline()
return lines
def write(self, s):