Author: Matti Picus <[email protected]>
Branch: 
Changeset: r93808:f2ff87a34f1f
Date: 2018-02-12 13:14 -0500
http://bitbucket.org/pypy/pypy/changeset/f2ff87a34f1f/

Log:    fix unicode wide/narrow test issues

diff --git a/pypy/interpreter/test/test_unicodehelper.py 
b/pypy/interpreter/test/test_unicodehelper.py
--- a/pypy/interpreter/test/test_unicodehelper.py
+++ b/pypy/interpreter/test/test_unicodehelper.py
@@ -1,5 +1,6 @@
 import pytest
 import struct
+import sys
 from pypy.interpreter.unicodehelper import (
     encode_utf8, decode_utf8, unicode_encode_utf_32_be)
 
@@ -26,7 +27,10 @@
     got = decode_utf8(space, "\xed\xa0\x80\xed\xb0\x80")
     assert map(ord, got) == [0xd800, 0xdc00]
     got = decode_utf8(space, "\xf0\x90\x80\x80")
-    assert map(ord, got) == [0x10000]
+    if sys.maxunicode > 65535:
+        assert map(ord, got) == [0x10000]
+    else:
+        assert map(ord, got) == [55296, 56320]
 
 @pytest.mark.parametrize('unich', [u"\ud800", u"\udc80"])
 def test_utf32_surrogates(unich):
diff --git a/pypy/module/_codecs/test/test_codecs.py 
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -538,11 +538,16 @@
         assert '\x00'.decode('unicode-internal', 'ignore') == ''
 
     def test_backslashreplace(self):
+        import sys
         sin = u"a\xac\u1234\u20ac\u8000\U0010ffff"
-        expected = "a\\xac\\u1234\\u20ac\\u8000\\U0010ffff"
-        assert sin.encode('ascii', 'backslashreplace') == expected
-        expected = "a\xac\\u1234\xa4\\u8000\\U0010ffff"
-        assert sin.encode("iso-8859-15", "backslashreplace") == expected
+        if sys.maxunicode > 65535:
+            expected_ascii = "a\\xac\\u1234\\u20ac\\u8000\\U0010ffff"
+            expected_8859 = "a\xac\\u1234\xa4\\u8000\\U0010ffff"
+        else:
+            expected_ascii = "a\\xac\\u1234\\u20ac\\u8000\\udbff\\udfff"
+            expected_8859 = "a\xac\\u1234\xa4\\u8000\\udbff\\udfff"
+        assert sin.encode('ascii', 'backslashreplace') == expected_ascii
+        assert sin.encode("iso-8859-15", "backslashreplace") == expected_8859
 
     def test_badhandler(self):
         import codecs
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to