From af5c7cff56f15432464f6058d7116ce9359abee5 Mon Sep 17 00:00:00 2001 From: Hye-Shik Chang Date: Sun, 17 Oct 2004 23:51:21 +0000 Subject: [PATCH] SF #1048865: Fix a trivial typo that breaks StreamReader.readlines() --- Lib/codecs.py | 2 +- Lib/test/test_codecs.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/codecs.py b/Lib/codecs.py index f831dd63375..ab12237f888 100644 --- a/Lib/codecs.py +++ b/Lib/codecs.py @@ -334,7 +334,7 @@ class StreamReader(Codec): """ data = self.read() - return self.splitlines(keepends) + return data.splitlines(keepends) def reset(self): diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 524c247d8c3..54d9da5b0ac 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -458,6 +458,16 @@ class CodecsModuleTest(unittest.TestCase): self.assertEquals(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'), '\xe4\xf6\xfc') +class StreamReaderTest(unittest.TestCase): + + def setUp(self): + self.reader = codecs.getreader('utf-8') + self.stream = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') + + def test_readlines(self): + f = self.reader(self.stream) + self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00']) + def test_main(): test_support.run_unittest( UTF16Test, @@ -469,7 +479,8 @@ def test_main(): PunycodeTest, NameprepTest, CodecTest, - CodecsModuleTest + CodecsModuleTest, + StreamReaderTest )