summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-29 22:36:49 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-29 22:36:49 (GMT)
commit84ec8d931404f4f9037242ec933fdcdcd4870114 (patch)
tree4936dae944a05bf26858b44065def904c8d23fac /Lib/test/test_codecs.py
parentf909202c11e0a304486c9fb71458e19a598d10c0 (diff)
downloadcpython-84ec8d931404f4f9037242ec933fdcdcd4870114.zip
cpython-84ec8d931404f4f9037242ec933fdcdcd4870114.tar.gz
cpython-84ec8d931404f4f9037242ec933fdcdcd4870114.tar.bz2
#6373: SystemError in str.encode('latin1', 'surrogateescape')
if the string contains unpaired surrogates. (In debug build, crash in assert()) This can happen with normal processing, if python starts with utf-8, then calls sys.setfilesystemencoding('latin-1')
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 4ec7b58..e060471 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1549,6 +1549,11 @@ class SurrogateEscapeTest(unittest.TestCase):
self.assertEqual("foo\udca5bar".encode("iso-8859-3", "surrogateescape"),
b"foo\xa5bar")
+ def test_latin1(self):
+ # Issue6373
+ self.assertEqual("\udce4\udceb\udcef\udcf6\udcfc".encode("latin1", "surrogateescape"),
+ b"\xe4\xeb\xef\xf6\xfc")
+
def test_main():
support.run_unittest(