]> granicus.if.org Git - python/commitdiff
Backported a test for lone surrogates support in io.StringIO.
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 29 Jan 2014 09:49:13 +0000 (11:49 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 29 Jan 2014 09:49:13 +0000 (11:49 +0200)
Lib/test/test_memoryio.py

index c3d559d6c43667c71078437e127936767329a03f..f6aef4e2bedc7de75c14f893cbe2cff6e7956c78 100644 (file)
@@ -588,6 +588,16 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin,
     UnsupportedOperation = pyio.UnsupportedOperation
     EOF = ""
 
+    def test_lone_surrogates(self):
+        # Issue #20424
+        surrogate = unichr(0xd800)
+        memio = self.ioclass(surrogate)
+        self.assertEqual(memio.read(), surrogate)
+
+        memio = self.ioclass()
+        memio.write(surrogate)
+        self.assertEqual(memio.getvalue(), surrogate)
+
 
 class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase):
     """Test if pickle restores properly the internal state of StringIO.