summaryrefslogtreecommitdiffstats
path: root/Lib/StringIO.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-25 14:56:01 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-25 14:56:01 (GMT)
commit2e2525fd3cb841cf4850a81c7bb95e97230c6964 (patch)
tree5116e5504df5cbadda85663325c2ff185006be8c /Lib/StringIO.py
parentb065452ebc45953d430a3bd745d52031e1a76c6b (diff)
downloadcpython-2e2525fd3cb841cf4850a81c7bb95e97230c6964.zip
cpython-2e2525fd3cb841cf4850a81c7bb95e97230c6964.tar.gz
cpython-2e2525fd3cb841cf4850a81c7bb95e97230c6964.tar.bz2
Patch by Lars Wirzenius to allow f.readline(length).
Diffstat (limited to 'Lib/StringIO.py')
-rw-r--r--Lib/StringIO.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index bbd9428..dba38e4 100644
--- a/Lib/StringIO.py
+++ b/Lib/StringIO.py
@@ -64,7 +64,7 @@ class StringIO:
r = self.buf[self.pos:newpos]
self.pos = newpos
return r
- def readline(self):
+ def readline(self, length=None):
if self.buflist:
self.buf = self.buf + string.joinfields(self.buflist, '')
self.buflist = []
@@ -73,6 +73,9 @@ class StringIO:
newpos = self.len
else:
newpos = i+1
+ if length is not None:
+ if self.pos + length < newpos:
+ newpos = self.pos + length
r = self.buf[self.pos:newpos]
self.pos = newpos
return r