summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-11-15 00:44:16 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-11-15 00:44:16 (GMT)
commit78edf7576e4bef16a5eda86cbbb912f5ffb208ec (patch)
tree64affea863ba10d3cd0b588254818d7813aaafa6 /Lib/test
parent9a812cbc899caeb25ab523e904dfac02e4da2999 (diff)
parent5418ee0b9a36886064937159f9c0641ae2c4f618 (diff)
downloadcpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.zip
cpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.tar.gz
cpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.tar.bz2
Issue #13333: The UTF-7 decoder now accepts lone surrogates
(the encoder already accepts them).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_unicode.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 5b044e2..406e585 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1108,10 +1108,18 @@ class UnicodeTest(string_tests.CommonTest,
for (x, y) in utfTests:
self.assertEqual(x.encode('utf-7'), y)
- # Unpaired surrogates not supported
- self.assertRaises(UnicodeError, str, b'+3ADYAA-', 'utf-7')
-
- self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd\ufffd')
+ # Unpaired surrogates are passed through
+ self.assertEqual('\uD801'.encode('utf-7'), b'+2AE-')
+ self.assertEqual('\uD801x'.encode('utf-7'), b'+2AE-x')
+ self.assertEqual('\uDC01'.encode('utf-7'), b'+3AE-')
+ self.assertEqual('\uDC01x'.encode('utf-7'), b'+3AE-x')
+ self.assertEqual(b'+2AE-'.decode('utf-7'), '\uD801')
+ self.assertEqual(b'+2AE-x'.decode('utf-7'), '\uD801x')
+ self.assertEqual(b'+3AE-'.decode('utf-7'), '\uDC01')
+ self.assertEqual(b'+3AE-x'.decode('utf-7'), '\uDC01x')
+
+ self.assertEqual('\uD801\U000abcde'.encode('utf-7'), b'+2AHab9ze-')
+ self.assertEqual(b'+2AHab9ze-'.decode('utf-7'), '\uD801\U000abcde')
# Issue #2242: crash on some Windows/MSVC versions
self.assertEqual(b'+\xc1'.decode('utf-7'), '\xc1')