[pypy-commit] pypy default: Wrong, we can't say "final" in StreamWriter.write().

arigo noreply at buildbot.pypy.org
Mon Aug 1 18:08:40 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r46159:1a4938c4eb0a
Date: 2011-08-01 17:46 +0200
http://bitbucket.org/pypy/pypy/changeset/1a4938c4eb0a/

Log:	Wrong, we can't say "final" in StreamWriter.write().

diff --git a/pypy/module/_multibytecodec/app_multibytecodec.py b/pypy/module/_multibytecodec/app_multibytecodec.py
--- a/pypy/module/_multibytecodec/app_multibytecodec.py
+++ b/pypy/module/_multibytecodec/app_multibytecodec.py
@@ -40,7 +40,7 @@
         return self
 
     def write(self, data):
-        self.stream.write(MultibyteIncrementalEncoder.encode(self, data, True))
+        self.stream.write(MultibyteIncrementalEncoder.encode(self, data))
 
     def writelines(self, lines):
         for data in lines:
diff --git a/pypy/module/_multibytecodec/test/test_app_stream.py b/pypy/module/_multibytecodec/test/test_app_stream.py
--- a/pypy/module/_multibytecodec/test/test_app_stream.py
+++ b/pypy/module/_multibytecodec/test/test_app_stream.py
@@ -22,6 +22,15 @@
 
             return HzStreamWriter
         """)
+        cls.w_ShiftJisx0213StreamWriter = cls.space.appexec([], """():
+            import _codecs_jp
+            from _multibytecodec import MultibyteStreamWriter
+
+            class ShiftJisx0213StreamWriter(MultibyteStreamWriter):
+                codec = _codecs_jp.getcodec('shift_jisx0213')
+
+            return ShiftJisx0213StreamWriter
+        """)
 
     def test_reader(self):
         class FakeFile:
@@ -69,3 +78,16 @@
             w.write(input)
         assert w.stream.output == ['!', '徕', '沅', 'x', 'y', 'z',
                                    '彐', '玷']
+
+    def test_no_flush(self):
+        class FakeFile:
+            def __init__(self):
+                self.output = []
+            def write(self, data):
+                self.output.append(data)
+        #
+        w = self.ShiftJisx0213StreamWriter(FakeFile())
+        w.write(u'\u30ce')
+        w.write(u'\u304b')
+        w.write(u'\u309a')
+        assert w.stream.output == ['\x83m', '', '\x82\xf5']


More information about the pypy-commit mailing list