Mercurial > cpython-lru_cache-weakref
diff Lib/StringIO.py @ 14680:e2d62d747f7a legacy-trunk
Support sizehint in StringIO.readlines, as documented.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Tue, 19 Sep 2000 11:07:44 +0000 |
| parents | d7eca5b0960a |
| children | b15fce868e50 |
line wrap: on
line diff
--- a/Lib/StringIO.py Tue Sep 19 11:06:46 2000 +0000 +++ b/Lib/StringIO.py Tue Sep 19 11:07:44 2000 +0000 @@ -91,11 +91,15 @@ 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):
