[pypy-commit] pypy py3.5: translation fixes
arigo
pypy.commits at gmail.com
Sat Feb 18 11:03:10 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r90181:6a6b47616053
Date: 2017-02-18 17:02 +0100
http://bitbucket.org/pypy/pypy/changeset/6a6b47616053/
Log: translation fixes
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1553,6 +1553,13 @@
return w_obj.buffer_w(self, self.BUF_SIMPLE)
except BufferInterfaceNotFound:
self._getarg_error("bytes-like object", w_obj)
+ elif code == 'y#':
+ if self.isinstance_w(w_obj, self.w_bytes):
+ return w_obj.bytes_w(self)
+ try:
+ return w_obj.buffer_w(self, self.BUF_SIMPLE).as_str()
+ except BufferInterfaceNotFound:
+ self._getarg_error("bytes-like object", w_obj)
else:
assert False
diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -154,7 +154,7 @@
# If allow_surrogates=True, then revert to the Python 2 behavior
# which never raises UnicodeEncodeError. Surrogate pairs are then
# allowed, either paired or lone. A paired surrogate is considered
- # like the non-BMP character it stands for. See also unicode_utf8sp().
+ # like the non-BMP character it stands for. See also *_utf8sp().
return runicode.unicode_encode_utf_8(
uni, len(uni), "strict",
errorhandler=encode_error_handler(space),
diff --git a/pypy/module/_codecs/locale.py b/pypy/module/_codecs/locale.py
--- a/pypy/module/_codecs/locale.py
+++ b/pypy/module/_codecs/locale.py
@@ -13,8 +13,6 @@
from rpython.translator import cdir
from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from pypy.interpreter.error import strerror as _strerror
-
cwd = py.path.local(__file__).dirpath()
eci = ExternalCompilationInfo(
includes=[cwd.join('locale_codec.h')],
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -167,12 +167,12 @@
if w_value:
w_error = space.call_function(w_type,
space.newint(errno),
- space.newtext(msg),
+ space.newunicode(msg),
w_value)
else:
w_error = space.call_function(w_type,
space.newint(errno),
- space.newtext(msg))
+ space.newunicode(msg))
raise OperationError(w_type, w_error)
@cpython_api([], rffi.INT_real, error=-1)
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -111,7 +111,8 @@
space.setattr(w_mod, space.newtext('__file__'), space.newtext(filename))
space.setattr(w_mod, space.newtext('__doc__'), space.w_None)
if pkgdir is not None:
- space.setattr(w_mod, space.newtext('__path__'), space.newlist([w(pkgdir)]))
+ space.setattr(w_mod, space.newtext('__path__'),
+ space.newlist([space.newtext(pkgdir)]))
init_extra_module_attrs(space, w_mod)
def add_module(space, w_name):
diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py
--- a/pypy/module/mmap/interp_mmap.py
+++ b/pypy/module/mmap/interp_mmap.py
@@ -53,7 +53,7 @@
def find(self, w_tofind, w_start=None, w_end=None):
self.check_valid()
space = self.space
- tofind = space.getarg_w('y*', w_tofind)
+ tofind = space.getarg_w('y#', w_tofind)
if w_start is None:
start = self.mmap.pos
else:
@@ -67,7 +67,7 @@
def rfind(self, w_tofind, w_start=None, w_end=None):
self.check_valid()
space = self.space
- tofind = space.getarg_w('y*', w_tofind)
+ tofind = space.getarg_w('y#', w_tofind)
if w_start is None:
start = self.mmap.pos
else:
@@ -99,7 +99,7 @@
def write(self, w_data):
self.check_valid()
- data = self.space.getarg_w('y*', w_data)
+ data = self.space.getarg_w('y#', w_data)
self.check_writeable()
try:
self.mmap.write(data)
diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -573,7 +573,7 @@
lltype.free(t_ref, flavor='raw')
if not pbuf:
raise OperationError(space.w_ValueError,
- space.newtext(_get_error_msg()))
+ space.newunicode(_get_error_msg()))
return pbuf
tup_w = space.fixedview(w_tup)
@@ -738,7 +738,8 @@
lltype.free(t_ref, flavor='raw')
if not p:
- raise OperationError(space.w_ValueError, space.newtext(_get_error_msg()))
+ raise OperationError(space.w_ValueError,
+ space.newunicode(_get_error_msg()))
return _tm_to_tuple(space, p)
def localtime(space, w_seconds=None):
@@ -755,7 +756,8 @@
lltype.free(t_ref, flavor='raw')
if not p:
- raise OperationError(space.w_OSError, space.newtext(_get_error_msg()))
+ raise OperationError(space.w_OSError,
+ space.newunicode(_get_error_msg()))
return _tm_to_tuple(space, p)
def mktime(space, w_tup):
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -160,7 +160,7 @@
try:
unicode_x = x.decode('ascii')
except UnicodeDecodeError:
- unicode_x = self._wrap_string_old(x)
+ return self._wrap_string_old(x)
return self.newunicode(unicode_x)
if isinstance(x, unicode):
return self.newunicode(x)
@@ -176,8 +176,17 @@
def _wrap_string_old(self, x):
# XXX should disappear soon
- print 'WARNING: space.wrap() called on a non-ascii byte string: %r' % x
- return self.newtext(x)
+ print 'WARNING: space.wrap() called on a non-ascii byte string: %s' % (
+ self.text_w(self.repr(self.newbytes(x))),)
+ lst = []
+ for ch in x:
+ ch = ord(ch)
+ if ch > 127:
+ lst.append(u'\ufffd')
+ else:
+ lst.append(unichr(ch))
+ unicode_x = u''.join(lst)
+ return self.newunicode(unicode_x)
@not_rpython # only for tests
def _wrap_not_rpython(self, x):
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
@@ -424,9 +424,6 @@
def descr_rmod(self, space, w_values):
return mod_format(space, w_values, self, fmt_type=FORMAT_UNICODE)
- def descr_rmod(self, space, w_values):
- return mod_format(space, w_values, self, do_unicode=True)
-
def descr_translate(self, space, w_table):
selfvalue = self._value
w_sys = space.getbuiltinmodule('sys')
@@ -617,7 +614,6 @@
encoding = getdefaultencoding(space)
if errors is None or errors == 'strict':
if encoding == 'ascii':
- # XXX error handling
s = space.charbuf_w(w_obj)
try:
u = fast_str_decode_ascii(s)
More information about the pypy-commit
mailing list