Kaydet (Commit) a05fa1d9 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Support sizehint in StringIO.readlines, as documented.

üst c912a3a8
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment