summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-07-20 22:15:39 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-07-20 22:15:39 (GMT)
commitc9878e1b220b748788c3faa656257d5da4cd46c7 (patch)
tree93c82f0d65fecef02e121768f00181b4800fd2f6 /Lib/test
parent21c825417fc993d708c3ff57e2b8b97b09a20159 (diff)
downloadcpython-c9878e1b220b748788c3faa656257d5da4cd46c7.zip
cpython-c9878e1b220b748788c3faa656257d5da4cd46c7.tar.gz
cpython-c9878e1b220b748788c3faa656257d5da4cd46c7.tar.bz2
Make attributes and local variables in the StreamReader str objects instead
of unicode objects, so that codecs that do a str->str decoding won't promote the result to unicode. This fixes SF bug #1241507.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_codecs.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 4154ad2..5f799e0 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -663,6 +663,22 @@ class StreamReaderTest(unittest.TestCase):
f = self.reader(self.stream)
self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00'])
+class Str2StrTest(unittest.TestCase):
+
+ def test_read(self):
+ sin = "\x80".encode("base64_codec")
+ reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
+ sout = reader.read()
+ self.assertEqual(sout, "\x80")
+ self.assert_(isinstance(sout, str))
+
+ def test_readline(self):
+ sin = "\x80".encode("base64_codec")
+ reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
+ sout = reader.readline()
+ self.assertEqual(sout, "\x80")
+ self.assert_(isinstance(sout, str))
+
all_unicode_encodings = [
"ascii",
"base64_codec",
@@ -867,6 +883,7 @@ def test_main():
CodecTest,
CodecsModuleTest,
StreamReaderTest,
+ Str2StrTest,
BasicUnicodeTest,
BasicStrTest
)