]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport checkin:
authorWalter Dörwald <walter@livinglogic.de>
Thu, 1 Sep 2005 12:03:14 +0000 (12:03 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Thu, 1 Sep 2005 12:03:14 +0000 (12:03 +0000)
SF bug #1235646: codecs.StreamRecoder.next() now reencodes the data it reads
from the input stream, so that the output is a byte string in the correct
encoding instead of a unicode string.

Lib/codecs.py
Misc/NEWS

index 761cc0645166dd02e984968c0ea98f96e254159e..01adaefd9930c2b9e31caa5f7af0e9efaa349a0c 100644 (file)
@@ -556,7 +556,9 @@ class StreamRecoder:
     def next(self):
 
         """ Return the next decoded line from the input stream."""
-        return self.reader.next()
+        data = self.reader.next()
+        data, bytesencoded = self.encode(data, self.errors)
+        return data
 
     def __iter__(self):
         return self
index b265e33896dde185cd9cf2dbe7efb2aa9068f843..9a890d526c1f9edc3cd4552580fabaa4d8d66057 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -141,6 +141,9 @@ Library
   about illegal code points. The codec now supports PEP 293 style error
   handlers.
 
+- Bug #1235646: ``codecs.StreamRecoder.next()`` now reencodes the data it reads
+  from the input stream, so that the output is a byte string in the correct
+  encoding instead of a unicode string.
 
 Build
 -----