[pypy-commit] pypy unicode-utf8-py3: more translation fixes
mattip
pypy.commits at gmail.com
Mon Aug 6 03:19:29 EDT 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r94962:a39a0158002f
Date: 2018-08-06 00:15 -0700
http://bitbucket.org/pypy/pypy/changeset/a39a0158002f/
Log: more translation fixes
diff --git a/pypy/interpreter/astcompiler/fstring.py b/pypy/interpreter/astcompiler/fstring.py
--- a/pypy/interpreter/astcompiler/fstring.py
+++ b/pypy/interpreter/astcompiler/fstring.py
@@ -264,9 +264,8 @@
space = astbuilder.space
literal = parsestring.decode_unicode_utf8(space, literal, 0,
len(literal))
- return unicodehelper.decode_unicode_escape(space, literal)
- else:
- return literal.decode('utf-8')
+ literal, lgt, _ = unicodehelper.decode_unicode_escape(space, literal)
+ return literal.decode('utf-8')
def fstring_find_literal_and_expr(astbuilder, fstr, atom_node, rec):
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -223,6 +223,8 @@
w_start = space.getattr(w_exc, space.newtext('start'))
w_end = space.getattr(w_exc, space.newtext('end'))
size = space.int_w(w_end) - space.int_w(w_start)
+ if size < 0:
+ size = 0
if space.isinstance_w(w_exc, space.w_UnicodeEncodeError):
text = '?' * size
return space.newtuple([space.newutf8(text, size), w_end])
@@ -315,7 +317,7 @@
try:
name = unicodedb.name(oc)
except KeyError:
- raw_unicode_escape_helper_unicode(builder, oc)
+ unicodehelper.raw_unicode_escape_helper(builder, oc)
else:
builder.append('\\N{')
builder.append(name)
diff --git a/pypy/module/_io/interp_stringio.py b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -156,10 +156,11 @@
def descr_getstate(self, space):
w_initialval = self.getvalue_w(space)
w_dict = space.call_method(self.w_dict, "copy")
- if self.readnl is None:
+ readnl = self.readnl
+ if readnl is None:
w_readnl = space.w_None
else:
- w_readnl = space.str(space.newutf8(self.readnl, get_utf8_length(self.readnl))) # YYY
+ w_readnl = space.str(space.newutf8(readnl, get_utf8_length(readnl))) # YYY
return space.newtuple([
w_initialval, w_readnl, space.newint(self.buf.pos), w_dict
])
More information about the pypy-commit
mailing list