Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r96515:a229b0127567
Date: 2019-04-18 11:02 +0200
http://bitbucket.org/pypy/pypy/changeset/a229b0127567/

Log:    Test and fix for unicode.translate()

diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -711,6 +711,7 @@
 
         raises(TypeError, u'hello'.translate)
         raises(TypeError, u'abababc'.translate, {ord('a'):''})
+        raises(TypeError, u'x'.translate, {ord('x'):0x110000})
 
     def test_unicode_from_encoded_object(self):
         assert unicode('x', 'utf-8') == u'x'
@@ -1278,4 +1279,4 @@
         assert str(e.value) == 'decoding Unicode is not supported'
 
     def test_newlist_utf8_non_ascii(self):
-        '&#228;'.split("\n")[0] # does not crash
\ No newline at end of file
+        '&#228;'.split("\n")[0] # does not crash
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -382,7 +382,7 @@
                                 "or unicode")
             try:
                 builder.append_code(codepoint)
-            except ValueError:
+            except rutf8.OutOfRange:
                 raise oefmt(space.w_TypeError,
                             "character mapping must be in range(0x110000)")
         return self.from_utf8builder(builder)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to