diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-03-23 09:55:29 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-03-23 09:55:29 (GMT) |
commit | 9a0d3462fcac06cb257b77cad464d01d348f702c (patch) | |
tree | 268f736c3972c2f1ca590b8b5e23d5363f842c25 /Lib | |
parent | 61854332b932d1d561fc58f815056d008e86ddd3 (diff) | |
download | cpython-9a0d3462fcac06cb257b77cad464d01d348f702c.zip cpython-9a0d3462fcac06cb257b77cad464d01d348f702c.tar.gz cpython-9a0d3462fcac06cb257b77cad464d01d348f702c.tar.bz2 |
#1477: ur'\U0010FFFF' raised in narrow unicode builds.
Corrected the raw-unicode-escape codec to use UTF-16 surrogates in
this case, just like the unicode-escape codec.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_unicode.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index bdc7192..24e8e77 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 as 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: |