[Python-checkins] cpython (3.3): Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
serhiy.storchaka
python-checkins at python.org
Wed Jan 29 10:49:32 CET 2014
http://hg.python.org/cpython/rev/6ca9ba9eb76b
changeset: 88805:6ca9ba9eb76b
branch: 3.3
parent: 88802:14782875030c
user: Serhiy Storchaka <storchaka at gmail.com>
date: Wed Jan 29 11:33:26 2014 +0200
summary:
Issue #20424: Python implementation of io.StringIO now supports lone surrogates.
files:
Lib/_pyio.py | 2 +-
Lib/test/test_memoryio.py | 9 +++++++++
Misc/NEWS | 2 ++
3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -2044,7 +2044,7 @@
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
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -609,6 +609,15 @@
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.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,8 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list