From: Martin v. Löwis Date: Tue, 19 Sep 2000 11:07:44 +0000 (+0000) Subject: Support sizehint in StringIO.readlines, as documented. X-Git-Tag: v2.0b2~205 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a05fa1d9d42cc1fcefa38ad893320d4d9e82bf61;p=thirdparty%2FPython%2Fcpython.git Support sizehint in StringIO.readlines, as documented. --- diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 8efd7d8c48f9..02eb7c8bec94 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -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):