[pypy-commit] pypy unicode-utf8-py3: translation fixes

mattip pypy.commits at gmail.com
Sun Aug 5 14:13:29 EDT 2018


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r94952:ff1a45089342
Date: 2018-08-05 11:09 -0700
http://bitbucket.org/pypy/pypy/changeset/ff1a45089342/

Log:	translation fixes

diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -39,8 +39,7 @@
     # Fast version of the "strict" errors handler.
     def raise_unicode_exception_encode(errors, encoding, msg, utf8,
                                        startingpos, endingpos):
-        if isinstance(utf8, unicode):
-            utf8 = utf8.encode('utf8')
+        assert not isinstance(utf8, unicode)
         u_len = rutf8.get_utf8_length(utf8)
         raise OperationError(space.w_UnicodeEncodeError,
                              space.newtuple([space.newtext(encoding),
@@ -362,7 +361,7 @@
                 if not final:
                     pos -= 1
                     break
-                r, pos = errorhandler(errors, "utf8", "unexpected end of data",
+                r, pos, lgt = errorhandler(errors, "utf8", "unexpected end of data",
                     s, pos - 1, pos + 1)
                 res.append(r)
                 continue
diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -182,10 +182,10 @@
         else:
             typename = space.type(w_obj).getname(space)
             objname = w_obj.getname(space)
-            if objname and objname != u'?':
-                state = u"; to '%s' (%s)" % (typename, objname)
+            if objname and objname != '?':
+                state = "; to '%s' (%s)" % (typename, objname)
             else:
-                state = u"; to '%s'" % (typename,)
+                state = "; to '%s'" % (typename,)
         return self.getrepr(space, unicode(self.typedef.name), state)
 
 
diff --git a/pypy/module/unicodedata/interp_ucd.py b/pypy/module/unicodedata/interp_ucd.py
--- a/pypy/module/unicodedata/interp_ucd.py
+++ b/pypy/module/unicodedata/interp_ucd.py
@@ -6,7 +6,7 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
-from rpython.rlib.rarithmetic import r_longlong
+from rpython.rlib.rarithmetic import r_longlong, r_uint
 from rpython.rlib.unicodedata import unicodedb_8_0_0, unicodedb_3_2_0
 from rpython.rlib.rutf8 import Utf8StringBuilder, unichr_as_utf8
 
@@ -82,7 +82,7 @@
         sequence = self._lookup_named_sequence(code)
         if sequence is not None:
             # named sequences only contain UCS2 codes, no surrogates &co.
-            return space.newutf8(unichr_as_utf8(code), 1)
+            return space.newutf8(unichr_as_utf8(r_uint(code)), 1)
 
 
 
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1438,7 +1438,7 @@
         typename = space.type(self).getname(space)
         w_seq = space.call_function(space.w_list, self)
         seq_repr = space.utf8_w(space.repr(w_seq))
-        return space.newtext(u"%s(%s)" % (typename, seq_repr.decode('utf8')))
+        return space.newtext("%s(%s)" % (typename, seq_repr))
 
     def descr_len(self, space):
         return space.len(self.w_dict)


More information about the pypy-commit mailing list