summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-11-06 16:53:44 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-11-06 16:53:44 (GMT)
commit4dbf192f2b7d267636244de70faf8c5d78790655 (patch)
tree0d0eef72d45e1aa982a4c1658828c5db2dad6dd0 /Lib
parent07e147667cf02cbcb05c84fe03fee31ef61a21c4 (diff)
downloadcpython-4dbf192f2b7d267636244de70faf8c5d78790655.zip
cpython-4dbf192f2b7d267636244de70faf8c5d78790655.tar.gz
cpython-4dbf192f2b7d267636244de70faf8c5d78790655.tar.bz2
Add next() and __iter__() methods to StreamReader, StreamReaderWriter
and StreamRecoder. This closes SF bug #634246.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/codecs.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py
index 40f0a2e..0b43a72 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -299,6 +299,17 @@ class StreamReader(Codec):
"""
pass
+ def next(self):
+
+ """ Return the next decoded line from the input stream."""
+ line = self.readline()
+ if line:
+ return line
+ raise StopIteration
+
+ def __iter__(self):
+ return self
+
def __getattr__(self, name,
getattr=getattr):
@@ -351,6 +362,14 @@ class StreamReaderWriter:
return self.reader.readlines(sizehint)
+ def next(self):
+
+ """ Return the next decoded line from the input stream."""
+ return self.reader.next()
+
+ def __iter__(self):
+ return self
+
def write(self, data):
return self.writer.write(data)
@@ -451,6 +470,14 @@ class StreamRecoder:
data, bytesencoded = self.encode(data, self.errors)
return data.splitlines(1)
+ def next(self):
+
+ """ Return the next decoded line from the input stream."""
+ return self.reader.next()
+
+ def __iter__(self):
+ return self
+
def write(self, data):
data, bytesdecoded = self.decode(data, self.errors)