diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-29 11:33:26 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-29 11:33:26 +0200 |
commit | c92ea76f3f43e367e9bf5fd12713c3b99ffad84a (patch) | |
tree | 6c37cfe6ff390163e3c588658d9090e10d7d4b93 | |
parent | 1e40295af6be0e43e62a22300cbdfb62e28f237d (diff) | |
download | cpython-git-c92ea76f3f43e367e9bf5fd12713c3b99ffad84a.tar.gz |
Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
-rw-r--r-- | Lib/_pyio.py | 2 | ||||
-rw-r--r-- | Lib/test/test_memoryio.py | 9 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
3 files changed, 12 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index aab60db4be..a9b00640f9 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -2044,7 +2044,7 @@ class StringIO(TextIOWrapper): def __init__(self, initial_value="", newline="\n"): super(StringIO, self).__init__(BytesIO(), encoding="utf-8", - errors="strict", + errors="surrogatepass", newline=newline) # Issue #5645: make universal newlines semantics the same as in the # C version, even under Windows. diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index d611a3138b..50c91ab20d 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -609,6 +609,15 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, UnsupportedOperation = pyio.UnsupportedOperation EOF = "" + def test_lone_surrogates(self): + # Issue #20424 + memio = self.ioclass('\ud800') + self.assertEqual(memio.read(), '\ud800') + + memio = self.ioclass() + memio.write('\ud800') + self.assertEqual(memio.getvalue(), '\ud800') + class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase): """Test if pickle restores properly the internal state of StringIO. @@ -50,6 +50,8 @@ Core and Builtins Library ------- +- Issue #20424: Python implementation of io.StringIO now supports lone surrogates. + - Issue #19456: ntpath.join() now joins relative paths correctly when a drive is present. |