From: Serhiy Storchaka Date: Wed, 29 Jan 2014 09:49:13 +0000 (+0200) Subject: Backported a test for lone surrogates support in io.StringIO. X-Git-Tag: v2.7.8~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47cb38cdcc3e16d77ecc9808ad669181ce54b246;p=python Backported a test for lone surrogates support in io.StringIO. --- diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index c3d559d6c4..f6aef4e2be 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -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.