Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
This commit is contained in:
parent
1e40295af6
commit
c92ea76f3f
@ -2044,7 +2044,7 @@ class StringIO(TextIOWrapper):
|
|||||||
def __init__(self, initial_value="", newline="\n"):
|
def __init__(self, initial_value="", newline="\n"):
|
||||||
super(StringIO, self).__init__(BytesIO(),
|
super(StringIO, self).__init__(BytesIO(),
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
errors="strict",
|
errors="surrogatepass",
|
||||||
newline=newline)
|
newline=newline)
|
||||||
# Issue #5645: make universal newlines semantics the same as in the
|
# Issue #5645: make universal newlines semantics the same as in the
|
||||||
# C version, even under Windows.
|
# C version, even under Windows.
|
||||||
|
@ -609,6 +609,15 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin,
|
|||||||
UnsupportedOperation = pyio.UnsupportedOperation
|
UnsupportedOperation = pyio.UnsupportedOperation
|
||||||
EOF = ""
|
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):
|
class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase):
|
||||||
"""Test if pickle restores properly the internal state of StringIO.
|
"""Test if pickle restores properly the internal state of StringIO.
|
||||||
|
@ -50,6 +50,8 @@ Core and Builtins
|
|||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
|
||||||
|
|
||||||
- Issue #19456: ntpath.join() now joins relative paths correctly when a drive
|
- Issue #19456: ntpath.join() now joins relative paths correctly when a drive
|
||||||
is present.
|
is present.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user