Commit 9f2e46de authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #20424: Python implementation of io.StringIO now supports lone surrogates.

parents 61f56163 c92ea76f
......@@ -2052,7 +2052,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.
......
......@@ -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.
......
......@@ -13,6 +13,8 @@ Core and Builtins
Library
-------
- Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
- Issue #20308: inspect.signature now works on classes without user-defined
__init__ or __new__ methods.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment