diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2000-09-19 11:07:44 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2000-09-19 11:07:44 (GMT) |
commit | a05fa1d9d42cc1fcefa38ad893320d4d9e82bf61 (patch) | |
tree | 3e9dcc337267554eb6f5ab0f245ff5361cdf6a9f /Lib | |
parent | c912a3a8fd353fab8d075f0d449703b9174ec2b1 (diff) | |
download | cpython-a05fa1d9d42cc1fcefa38ad893320d4d9e82bf61.zip cpython-a05fa1d9d42cc1fcefa38ad893320d4d9e82bf61.tar.gz cpython-a05fa1d9d42cc1fcefa38ad893320d4d9e82bf61.tar.bz2 |
Support sizehint in StringIO.readlines, as documented.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/StringIO.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 8efd7d8..02eb7c8 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): |