summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-03-24 21:16:28 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-03-24 21:16:28 (GMT)
commita79e05097be27579d0ab0e38fda404b0edb670c0 (patch)
tree817e98d10f75e67b229ff5f79638f2f00d9a2091 /Lib/test/test_unicode.py
parentd9b9d680d502e9a776806184c13a9b1162cf6d06 (diff)
downloadcpython-a79e05097be27579d0ab0e38fda404b0edb670c0.zip
cpython-a79e05097be27579d0ab0e38fda404b0edb670c0.tar.gz
cpython-a79e05097be27579d0ab0e38fda404b0edb670c0.tar.bz2
#1477: ur'\U0010FFFF' used to raise in narrow unicode builds.
Corrected the raw-unicode-escape codec to use UTF-16 surrogates in this case, like the unicode-escape codec does. Backport of r61793 and r61853
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 4f75771..55fb8e1 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -736,12 +736,25 @@ class UnicodeTest(
print >>out, u'def\n'
def test_ucs4(self):
- if sys.maxunicode == 0xFFFF:
- return
x = u'\U00100000'
y = x.encode("raw-unicode-escape").decode("raw-unicode-escape")
self.assertEqual(x, y)
+ y = r'\U00100000'
+ x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
+ self.assertEqual(x, y)
+ y = r'\U00010000'
+ x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
+ self.assertEqual(x, y)
+
+ try:
+ '\U11111111'.decode("raw-unicode-escape")
+ except UnicodeDecodeError, e:
+ self.assertEqual(e.start, 0)
+ self.assertEqual(e.end, 10)
+ else:
+ self.fail("Should have raised UnicodeDecodeError")
+
def test_conversion(self):
# Make sure __unicode__() works properly
class Foo0: