[pypy-commit] pypy py3.6: Merged in joachim-ballmann/pypy/fix_test_unicode_outofrange (pull request #656)

rlamy pypy.commits at gmail.com
Sun Jul 14 06:56:32 EDT 2019


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.6
Changeset: r96991:167742e47bab
Date: 2019-07-14 10:56 +0000
http://bitbucket.org/pypy/pypy/changeset/167742e47bab/

Log:	Merged in joachim-ballmann/pypy/fix_test_unicode_outofrange (pull
	request #656)

	Fix test_unicode_outofrange

diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -899,16 +899,22 @@
         b.byteswap()
         assert b[2] == u'\u0000'
         assert a != b
-        e = raises(ValueError, "b[0]")        # doesn't work
-        assert str(e.value) == (
-            "cannot operate on this array('u') because it contains"
-            " character U+1000000 not in range [U+0000; U+10ffff]"
-            " at index 0")
+        if b.itemsize == 4:
+            e = raises(ValueError, "b[0]")        # doesn't work
+            assert str(e.value) == (
+                "cannot operate on this array('u') because it contains"
+                " character U+1000000 not in range [U+0000; U+10ffff]"
+                " at index 0")
+            assert str(b) == ("array('u', <character U+1000000 is not in"
+                          " range [U+0000; U+10ffff]>)")
+            raises(ValueError, b.tounicode)   # doesn't work
+        elif b.itemsize == 2:
+            assert b[0] == u'\u0100'
+            byteswaped_unicode = u'\u0100\u3a26\x00\ufffe'
+            assert str(b) == "array('u', %r)" % (byteswaped_unicode,)
+            assert b.tounicode() == byteswaped_unicode
         assert str(a) == "array('u', %r)" % (input_unicode,)
-        assert str(b) == ("array('u', <character U+1000000 is not in"
-                          " range [U+0000; U+10ffff]>)")
         assert a.tounicode() == input_unicode
-        raises(ValueError, b.tounicode)   # doesn't work
 
     def test_unicode_surrogate(self):
         a = self.array('u', u'\ud800')


More information about the pypy-commit mailing list