Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95960:5a61af129d87
Date: 2019-02-12 01:33 +0200
http://bitbucket.org/pypy/pypy/changeset/5a61af129d87/

Log:    fix logic, remove dead code

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
@@ -1901,8 +1901,7 @@
     utf8 = space.utf8_w(w_unistr)
     lgt =  space.len_w(w_unistr) 
     result = StringBuilder(lgt)
-    itr = rutf8.Utf8StringIterator(utf8)
-    for uchr in itr:
+    for uchr in rutf8.Utf8StringIterator(utf8):
         if uchr > 127:
             if unicodedb.isspace(uchr):
                 result.append(' ')
@@ -1910,23 +1909,9 @@
             try:
                 uchr = ord(u'0') + unicodedb.decimal(uchr)
             except KeyError:
-                w_encoding = space.newtext('decimal')
-                pos = itr.get_pos()
-                w_start = space.newint(pos)
-                w_end = space.newint(pos+1)
-                w_reason = space.newtext('invalid decimal Unicode string')
-                raise OperationError(space.w_UnicodeEncodeError,
-                                     space.newtuple([w_encoding, w_unistr,
-                                                     w_start, w_end,
-                                                     w_reason]))
-        result.append(chr(uchr))
+                pass
+        result.append(rutf8.unichr_as_utf8(r_uint(uchr), True))
     return result.build()
 
-from rpython.rlib.runicode import unicode_encode_utf8_forbid_surrogates
[email protected]
-def XXX_g_encode_utf8(value):
-    """This is a global function because of jit.conditional_call_value"""
-    return unicode_encode_utf8_forbid_surrogates(value, len(value))
-
 _repr_function = rutf8.make_utf8_escape_function(
     pass_printable=True, quotes=True, prefix='')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to