Author: Matti Picus <matti.pi...@gmail.com>
Branch: unicode-utf8
Changeset: r94848:6ebf80250b71
Date: 2018-07-11 06:46 -0700
http://bitbucket.org/pypy/pypy/changeset/6ebf80250b71/

Log:    modify never used rpython surrogate_in_utf8 to return index

diff --git a/rpython/rlib/rutf8.py b/rpython/rlib/rutf8.py
--- a/rpython/rlib/rutf8.py
+++ b/rpython/rlib/rutf8.py
@@ -471,8 +471,8 @@
     """
     for i in range(len(value) - 2):
         if value[i] == '\xed' and value[i + 1] >= '\xa0':
-            return True
-    return False
+            return i
+    return -1
 
 
 UTF8_INDEX_STORAGE = lltype.GcArray(lltype.Struct('utf8_loc_elem',
diff --git a/rpython/rlib/test/test_rutf8.py b/rpython/rlib/test/test_rutf8.py
--- a/rpython/rlib/test/test_rutf8.py
+++ b/rpython/rlib/test/test_rutf8.py
@@ -152,7 +152,7 @@
 @example([u'\ud800', u'\udc00'])
 def test_surrogate_in_utf8(unichars):
     uni = ''.join([u.encode('utf8') for u in unichars])
-    result = rutf8.surrogate_in_utf8(uni)
+    result = rutf8.surrogate_in_utf8(uni) < 0
     expected = any(uch for uch in unichars if u'\ud800' <= uch <= u'\udfff')
     assert result == expected
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to