[pypy-commit] pypy space-newtext: remove a lot of space.wrap calls in the objspace and replace them by space.new*
cfbolz
pypy.commits at gmail.com
Thu Oct 20 11:53:44 EDT 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: space-newtext
Changeset: r87897:adb61bdfea7e
Date: 2016-10-20 17:53 +0200
http://bitbucket.org/pypy/pypy/changeset/adb61bdfea7e/
Log: remove a lot of space.wrap calls in the objspace and replace them by
space.new* calls
diff too long, truncating to 2000 out of 2123 lines
diff --git a/pypy/doc/objspace.rst b/pypy/doc/objspace.rst
--- a/pypy/doc/objspace.rst
+++ b/pypy/doc/objspace.rst
@@ -208,6 +208,11 @@
is the type of the argument (which is rpython.rlib.rbigint.rbigint). On PyPy3 this
method will return an :py:class:`int` (PyPy2 it returns a :py:class:`long`).
+.. py:function:: newbytes(t)
+
+ The given argument is a rpython bytestring. Creates a wrapped object
+ of type :py:class:`bytes` (both on PyPy2 and PyPy3).
+
.. py:function:: newtext(t)
The given argument is a rpython bytestring. Creates a wrapped object
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -31,8 +31,8 @@
def create_entry_point(space, w_dict):
if w_dict is not None: # for tests
- w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
- w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
+ w_entry_point = space.getitem(w_dict, space.newtext('entry_point'))
+ w_run_toplevel = space.getitem(w_dict, space.newtext('run_toplevel'))
withjit = space.config.objspace.usemodules.pypyjit
def entry_point(argv):
@@ -55,8 +55,8 @@
try:
try:
space.startup()
- w_executable = space.wrap(argv[0])
- w_argv = space.newlist([space.wrap(s) for s in argv[1:]])
+ w_executable = space.newtext(argv[0])
+ w_argv = space.newlist([space.newtext(s) for s in argv[1:]])
w_exitcode = space.call_function(w_entry_point, w_executable, w_argv)
exitcode = space.int_w(w_exitcode)
# try to pull it all in
@@ -110,11 +110,11 @@
# import site
try:
space.setattr(space.getbuiltinmodule('sys'),
- space.wrap('executable'),
- space.wrap(home))
+ space.newtext('executable'),
+ space.newtext(home))
import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
- space.wrap('__import__'))
- space.call_function(import_, space.wrap('site'))
+ space.newtext('__import__'))
+ space.call_function(import_, space.newtext('site'))
return rffi.cast(rffi.INT, 0)
except OperationError as e:
if verbose:
@@ -156,11 +156,11 @@
def _pypy_execute_source(source, c_argument):
try:
w_globals = space.newdict(module=True)
- space.setitem(w_globals, space.wrap('__builtins__'),
+ space.setitem(w_globals, space.newtext('__builtins__'),
space.builtin_modules['__builtin__'])
- space.setitem(w_globals, space.wrap('c_argument'),
- space.wrap(c_argument))
- space.appexec([space.wrap(source), w_globals], """(src, glob):
+ space.setitem(w_globals, space.newtext('c_argument'),
+ space.newtext(c_argument))
+ space.appexec([space.newtext(source), w_globals], """(src, glob):
import sys
stmt = compile(src, 'c callback', 'exec')
if not hasattr(sys, '_pypy_execute_source'):
@@ -292,7 +292,7 @@
# obscure hack to stuff the translation options into the translated PyPy
import pypy.module.sys
options = make_dict(config)
- wrapstr = 'space.wrap(%r)' % (options)
+ wrapstr = 'space.newtext(%r)' % (options)
pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr
if config.objspace.usemodules._cffi_backend:
self.hack_for_cffi_modules(driver)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -86,8 +86,8 @@
def getaddrstring(self, space):
# slowish
w_id = space.id(self)
- w_4 = space.wrap(4)
- w_0x0F = space.wrap(0x0F)
+ w_4 = space.newint(4)
+ w_0x0F = space.newint(0x0F)
i = 2 * HUGEVAL_BYTES
addrstring = [' '] * i
while True:
diff --git a/pypy/interpreter/interactive.py b/pypy/interpreter/interactive.py
--- a/pypy/interpreter/interactive.py
+++ b/pypy/interpreter/interactive.py
@@ -99,7 +99,7 @@
# forbidden:
#space.exec_("__pytrace__ = 0", self.w_globals, self.w_globals)
- space.setitem(self.w_globals, space.wrap('__pytrace__'),space.wrap(0))
+ space.setitem(self.w_globals, space.wrap('__pytrace__'),space.newint(0))
self.tracelevel = 0
self.console_locals = {}
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -275,7 +275,7 @@
if w_descr is None:
raise oefmt(space.w_TypeError, "'%T' has no length", w_obj)
w_res = space.get_and_call_function(w_descr, w_obj)
- return space.wrap(space._check_len_result(w_res))
+ return space.newint(space._check_len_result(w_res))
def _check_len_result(space, w_obj):
# Will complain if result is too big.
@@ -451,12 +451,12 @@
# turn -1 into -2 without using a condition, which would
# create a potential bridge in the JIT
h -= (h == -1)
- return space.wrap(h)
+ return space.newint(h)
def cmp(space, w_v, w_w):
if space.is_w(w_v, w_w):
- return space.wrap(0)
+ return space.newint(0)
# The real comparison
if space.is_w(space.type(w_v), space.type(w_w)):
@@ -467,10 +467,10 @@
return w_res
# fall back to rich comparison.
if space.eq_w(w_v, w_w):
- return space.wrap(0)
+ return space.newint(0)
elif space.is_true(space.lt(w_v, w_w)):
- return space.wrap(-1)
- return space.wrap(1)
+ return space.newint(-1)
+ return space.newint(1)
def coerce(space, w_obj1, w_obj2):
w_res = space.try_coerce(w_obj1, w_obj2)
@@ -501,7 +501,7 @@
space.len_w(w_res) != 2):
raise oefmt(space.w_TypeError,
"coercion should return None or 2-tuple")
- w_res = space.newtuple([space.getitem(w_res, space.wrap(1)), space.getitem(w_res, space.wrap(0))])
+ w_res = space.newtuple([space.getitem(w_res, space.newint(1)), space.getitem(w_res, space.newint(0))])
elif (not space.isinstance_w(w_res, space.w_tuple) or
space.len_w(w_res) != 2):
raise oefmt(space.w_TypeError,
@@ -512,7 +512,7 @@
return space._type_issubtype(w_sub, w_type)
def issubtype(space, w_sub, w_type):
- return space.wrap(space._type_issubtype(w_sub, w_type))
+ return space.newbool(space._type_issubtype(w_sub, w_type))
@specialize.arg_or_var(2)
def isinstance_w(space, w_inst, w_type):
@@ -520,7 +520,7 @@
@specialize.arg_or_var(2)
def isinstance(space, w_inst, w_type):
- return space.wrap(space.isinstance_w(w_inst, w_type))
+ return space.newbool(space.isinstance_w(w_inst, w_type))
def index(space, w_obj):
if (space.isinstance_w(w_obj, space.w_int) or
@@ -584,11 +584,11 @@
return _conditional_neg(space, w_res, do_neg2)
# fall back to internal rules
if space.is_w(w_obj1, w_obj2):
- return space.wrap(0)
+ return space.newint(0)
if space.is_w(w_obj1, space.w_None):
- return space.wrap(-1)
+ return space.newint(-1)
if space.is_w(w_obj2, space.w_None):
- return space.wrap(1)
+ return space.newint(1)
if space.is_w(w_typ1, w_typ2):
#print "WARNING, comparison by address!"
lt = _id_cmpr(space, w_obj1, w_obj2, symbol)
@@ -610,9 +610,9 @@
else:
lt = _id_cmpr(space, w_typ1, w_typ2, symbol)
if lt:
- return space.wrap(-1)
+ return space.newint(-1)
else:
- return space.wrap(1)
+ return space.newint(1)
def _id_cmpr(space, w_obj1, w_obj2, symbol):
if symbol == "==":
@@ -658,19 +658,19 @@
"""Only for backward compatibility for __getslice__()&co methods."""
w_length = None
if space.is_w(w_start, space.w_None):
- w_start = space.wrap(0)
+ w_start = space.newint(0)
else:
start = space.getindex_w(w_start, None)
- w_start = space.wrap(start)
+ w_start = space.newint(start)
if start < 0:
w_length = old_slice_range_getlength(space, w_obj)
if w_length is not None:
w_start = space.add(w_start, w_length)
if space.is_w(w_stop, space.w_None):
- w_stop = space.wrap(slice_max)
+ w_stop = space.newint(slice_max)
else:
stop = space.getindex_w(w_stop, None)
- w_stop = space.wrap(stop)
+ w_stop = space.newint(stop)
if stop < 0:
if w_length is None:
w_length = old_slice_range_getlength(space, w_obj)
@@ -761,7 +761,7 @@
# fallback: lt(a, b) <= lt(cmp(a, b), 0) ...
w_res = _cmp(space, w_first, w_second, symbol)
res = space.int_w(w_res)
- return space.wrap(op(res, 0))
+ return space.newbool(op(res, 0))
return func_with_new_name(comparison_impl, 'comparison_%s_impl'%left.strip('_'))
@@ -869,7 +869,7 @@
"(type '%%T')", w_result)
else:
# re-wrap the result as a real string
- return space.wrap(result)
+ return space.newtext(result)
assert not hasattr(DescrOperation, %(targetname)r)
DescrOperation.%(targetname)s = %(targetname)s
del %(targetname)s
diff --git a/pypy/objspace/std/boolobject.py b/pypy/objspace/std/boolobject.py
--- a/pypy/objspace/std/boolobject.py
+++ b/pypy/objspace/std/boolobject.py
@@ -45,7 +45,7 @@
return space.newbool(space.is_true(w_obj))
def descr_repr(self, space):
- return space.wrap('True' if self.intval else 'False')
+ return space.newtext('True' if self.intval else 'False')
descr_str = func_with_new_name(descr_repr, 'descr_str')
def descr_nonzero(self, space):
diff --git a/pypy/objspace/std/bufferobject.py b/pypy/objspace/std/bufferobject.py
--- a/pypy/objspace/std/bufferobject.py
+++ b/pypy/objspace/std/bufferobject.py
@@ -51,12 +51,13 @@
return W_Buffer(buf)
def descr_len(self, space):
- return space.wrap(self.buf.getlength())
+ return space.newint(self.buf.getlength())
def descr_getitem(self, space, w_index):
start, stop, step, size = space.decode_index4(w_index,
self.buf.getlength())
if step == 0: # index only
+ import pdb; pdb.set_trace()
return space.wrap(self.buf.getitem(start))
res = self.buf.getslice(start, stop, step, size)
return space.wrap(res)
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -72,7 +72,7 @@
character = self.data[index]
except IndexError:
raise oefmt(space.w_IndexError, "bytearray index out of range")
- return space.wrap(ord(character))
+ return space.newint(ord(character))
def _val(self, space):
return self.data
@@ -156,7 +156,7 @@
raise oefmt(space.w_TypeError,
"ord() expected a character, but string of length %d "
"found", len(self.data))
- return space.wrap(ord(self.data[0]))
+ return space.newint(ord(self.data[0]))
@staticmethod
def descr_new(space, w_bytearraytype, __args__):
@@ -169,8 +169,8 @@
w_dict = space.w_None
return space.newtuple([
space.type(self), space.newtuple([
- space.wrap(''.join(self.data).decode('latin-1')),
- space.wrap('latin-1')]),
+ space.newunicode(''.join(self.data).decode('latin-1')),
+ space.newtext('latin-1')]),
w_dict])
@staticmethod
@@ -184,7 +184,7 @@
@unwrap_spec(encoding='str_or_None', errors='str_or_None')
def descr_init(self, space, w_source=None, encoding=None, errors=None):
if w_source is None:
- w_source = space.wrap('')
+ w_source = space.newbytes('')
if encoding is not None:
from pypy.objspace.std.unicodeobject import encode_object
# if w_source is an integer this correctly raises a
@@ -247,10 +247,10 @@
buf.append(quote)
buf.append(")")
- return space.wrap(buf.build())
+ return space.newtext(buf.build())
def descr_str(self, space):
- return space.wrap(''.join(self.data))
+ return space.newtext(''.join(self.data))
def descr_eq(self, space, w_other):
if isinstance(w_other, W_BytearrayObject):
@@ -424,7 +424,7 @@
if not self.data:
raise oefmt(space.w_IndexError, "pop from empty bytearray")
raise oefmt(space.w_IndexError, "pop index out of range")
- return space.wrap(ord(result))
+ return space.newint(ord(result))
def descr_remove(self, space, w_char):
char = space.int_w(space.index(w_char))
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -50,7 +50,7 @@
else:
base = 256 # empty string: base value 256
uid = (base << IDTAG_SHIFT) | IDTAG_SPECIAL
- return space.wrap(uid)
+ return space.newint(uid)
def unicode_w(self, space):
# Use the default encoding.
@@ -478,7 +478,7 @@
raise oefmt(space.w_TypeError,
"ord() expected a character, but string of length %d "
"found", len(self._value))
- return space.wrap(ord(self._value[0]))
+ return space.newint(ord(self._value[0]))
def _new(self, value):
return W_BytesObject(value)
@@ -581,7 +581,7 @@
quote = "'"
if quote in s and '"' not in s:
quote = '"'
- return space.wrap(string_escape_encode(s, quote))
+ return space.newtext(string_escape_encode(s, quote))
def descr_str(self, space):
if type(self) is W_BytesObject:
@@ -590,7 +590,7 @@
def descr_hash(self, space):
x = compute_hash(self._value)
- return space.wrap(x)
+ return space.newint(x)
def descr_format(self, space, __args__):
return newformat.format_method(space, self, __args__, is_unicode=False)
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -138,6 +138,6 @@
# fast method path: a function object in the class,
# nothing in the instance
return space.call_function(w_descr, w_obj, *arg_w)
- w_name = space.wrap(methname)
+ w_name = space.newtext(methname)
w_meth = space.getattr(w_obj, w_name)
return space.call_function(w_meth, *arg_w)
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -23,7 +23,7 @@
def _wrapkey(space, key):
- return space.wrap(key)
+ return space.newtext(key)
class ModuleDictStrategy(DictStrategy):
diff --git a/pypy/objspace/std/classdict.py b/pypy/objspace/std/classdict.py
--- a/pypy/objspace/std/classdict.py
+++ b/pypy/objspace/std/classdict.py
@@ -90,7 +90,7 @@
def items(self, w_dict):
space = self.space
- return [space.newtuple([space.wrap(key), unwrap_cell(self.space, w_value)])
+ return [space.newtuple([space.newtext(key), unwrap_cell(self.space, w_value)])
for (key, w_value) in self.unerase(w_dict.dstorage).dict_w.iteritems()]
def clear(self, w_dict):
@@ -112,7 +112,7 @@
return iteritems_with_hash(self.unerase(w_dict.dstorage).dict_w)
def wrapkey(space, key):
- return space.wrap(key)
+ return space.newtext(key)
def wrapvalue(space, value):
return unwrap_cell(space, value)
diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -143,7 +143,7 @@
w_z = None
if space.is_oldstyle_instance(w_complex):
try:
- w_method = space.getattr(w_complex, space.wrap('__complex__'))
+ w_method = space.getattr(w_complex, space.newtext('__complex__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise
@@ -170,8 +170,8 @@
# no '__complex__' method, so we assume it is a float,
# unless it is an instance of some subclass of complex.
if space.isinstance_w(w_complex, space.gettypefor(W_ComplexObject)):
- real = space.float(space.getattr(w_complex, space.wrap("real")))
- imag = space.float(space.getattr(w_complex, space.wrap("imag")))
+ real = space.float(space.getattr(w_complex, space.newtext("real")))
+ imag = space.float(space.getattr(w_complex, space.newtext("imag")))
return (space.float_w(real), space.float_w(imag))
#
# Check that it is not a string (on which space.float() would succeed).
@@ -214,7 +214,7 @@
return W_ComplexObject(rr, ir)
def divmod(self, space, other):
- space.warn(space.wrap("complex divmod(), // and % are deprecated"),
+ space.warn(space.newtext("complex divmod(), // and % are deprecated"),
space.w_DeprecationWarning)
w_div = self.div(other)
div = math.floor(w_div.realval)
@@ -251,10 +251,10 @@
return False
if self.user_overridden_class or w_other.user_overridden_class:
return self is w_other
- real1 = space.float_w(space.getattr(self, space.wrap("real")))
- real2 = space.float_w(space.getattr(w_other, space.wrap("real")))
- imag1 = space.float_w(space.getattr(self, space.wrap("imag")))
- imag2 = space.float_w(space.getattr(w_other, space.wrap("imag")))
+ real1 = space.float_w(space.getattr(self, space.newtext("real")))
+ real2 = space.float_w(space.getattr(w_other, space.newtext("real")))
+ imag1 = space.float_w(space.getattr(self, space.newtext("imag")))
+ imag2 = space.float_w(space.getattr(w_other, space.newtext("imag")))
real1 = float2longlong(real1)
real2 = float2longlong(real2)
imag1 = float2longlong(imag1)
@@ -267,8 +267,8 @@
from rpython.rlib.longlong2float import float2longlong
from pypy.objspace.std.util import IDTAG_COMPLEX as tag
from pypy.objspace.std.util import IDTAG_SHIFT
- real = space.float_w(space.getattr(self, space.wrap("real")))
- imag = space.float_w(space.getattr(self, space.wrap("imag")))
+ real = space.float_w(space.getattr(self, space.newtext("real")))
+ imag = space.float_w(space.getattr(self, space.newtext("imag")))
real_b = rbigint.fromrarith_int(float2longlong(real))
imag_b = rbigint.fromrarith_int(r_ulonglong(float2longlong(imag)))
val = real_b.lshift(64).or_(imag_b).lshift(IDTAG_SHIFT).int_or_(tag)
@@ -347,19 +347,19 @@
def descr_repr(self, space):
if self.realval == 0 and copysign(1., self.realval) == 1.:
- return space.wrap(repr_format(self.imagval) + 'j')
+ return space.newtext(repr_format(self.imagval) + 'j')
sign = (copysign(1., self.imagval) == 1. or
isnan(self.imagval)) and '+' or ''
- return space.wrap('(' + repr_format(self.realval)
- + sign + repr_format(self.imagval) + 'j)')
+ return space.newtext('(' + repr_format(self.realval)
+ + sign + repr_format(self.imagval) + 'j)')
def descr_str(self, space):
if self.realval == 0 and copysign(1., self.realval) == 1.:
- return space.wrap(str_format(self.imagval) + 'j')
+ return space.newtext(str_format(self.imagval) + 'j')
sign = (copysign(1., self.imagval) == 1. or
isnan(self.imagval)) and '+' or ''
- return space.wrap('(' + str_format(self.realval)
- + sign + str_format(self.imagval) + 'j)')
+ return space.newtext('(' + str_format(self.realval)
+ + sign + str_format(self.imagval) + 'j)')
def descr_hash(self, space):
hashreal = _hash_float(space, self.realval)
@@ -394,7 +394,7 @@
try:
return space.newfloat(math.hypot(self.realval, self.imagval))
except OverflowError as e:
- raise OperationError(space.w_OverflowError, space.wrap(str(e)))
+ raise OperationError(space.w_OverflowError, space.newtext(str(e)))
def descr_eq(self, space, w_other):
if isinstance(w_other, W_ComplexObject):
@@ -476,7 +476,7 @@
try:
return self.div(w_rhs)
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_rtruediv(self, space, w_lhs):
w_lhs = self._to_complex(space, w_lhs)
@@ -485,7 +485,7 @@
try:
return w_lhs.div(self)
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_floordiv(self, space, w_rhs):
w_rhs = self._to_complex(space, w_rhs)
@@ -495,7 +495,7 @@
try:
return self.divmod(space, w_rhs)[0]
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_rfloordiv(self, space, w_lhs):
w_lhs = self._to_complex(space, w_lhs)
@@ -505,7 +505,7 @@
try:
return w_lhs.divmod(space, self)[0]
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_mod(self, space, w_rhs):
w_rhs = self._to_complex(space, w_rhs)
@@ -514,7 +514,7 @@
try:
return self.divmod(space, w_rhs)[1]
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_rmod(self, space, w_lhs):
w_lhs = self._to_complex(space, w_lhs)
@@ -523,7 +523,7 @@
try:
return w_lhs.divmod(space, self)[1]
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
def descr_divmod(self, space, w_rhs):
w_rhs = self._to_complex(space, w_rhs)
@@ -532,7 +532,7 @@
try:
div, mod = self.divmod(space, w_rhs)
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
return space.newtuple([div, mod])
def descr_rdivmod(self, space, w_lhs):
@@ -542,7 +542,7 @@
try:
div, mod = w_lhs.divmod(space, self)
except ZeroDivisionError as e:
- raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
+ raise OperationError(space.w_ZeroDivisionError, space.newtext(str(e)))
return space.newtuple([div, mod])
@unwrap_spec(w_third_arg=WrappedDefault(None))
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
@@ -209,7 +209,7 @@
descr_ge = negate(descr_lt)
def descr_len(self, space):
- return space.wrap(self.length())
+ return space.newint(self.length())
def descr_iter(self, space):
return W_DictMultiIterKeysObject(space, self.iterkeys())
@@ -926,7 +926,7 @@
def setitem_str(self, w_dict, key, w_value):
self.switch_to_object_strategy(w_dict)
- w_dict.setitem(self.space.wrap(key), w_value)
+ w_dict.setitem(self.space.newtext(key), w_value)
def setdefault(self, w_dict, w_key, w_default):
if self.is_correct_type(w_key):
@@ -948,7 +948,7 @@
return len(self.unerase(w_dict.dstorage))
def getitem_str(self, w_dict, key):
- return self.getitem(w_dict, self.space.wrap(key))
+ return self.getitem(w_dict, self.space.newtext(key))
def getitem(self, w_dict, w_key):
space = self.space
@@ -1039,7 +1039,7 @@
return self.space.newlist(self.unerase(w_dict.dstorage).keys())
def setitem_str(self, w_dict, s, w_value):
- self.setitem(w_dict, self.space.wrap(s), w_value)
+ self.setitem(w_dict, self.space.newtext(s), w_value)
def switch_to_object_strategy(self, w_dict):
assert 0, "should be unreachable"
@@ -1053,10 +1053,10 @@
unerase = staticmethod(unerase)
def wrap(self, unwrapped):
- return self.space.wrap(unwrapped)
+ return self.space.newbytes(unwrapped)
def unwrap(self, wrapped):
- return self.space.str_w(wrapped)
+ return self.space.bytes_w(wrapped)
def is_correct_type(self, w_obj):
space = self.space
@@ -1093,7 +1093,7 @@
return self.space.newlist_bytes(self.listview_bytes(w_dict))
def wrapkey(space, key):
- return space.wrap(key)
+ return space.newbytes(key)
@jit.look_inside_iff(lambda self, w_dict:
w_dict_unrolling_heuristic(w_dict))
@@ -1117,7 +1117,7 @@
unerase = staticmethod(unerase)
def wrap(self, unwrapped):
- return self.space.wrap(unwrapped)
+ return self.space.newunicode(unwrapped)
def unwrap(self, wrapped):
return self.space.unicode_w(wrapped)
@@ -1159,7 +1159,7 @@
## return self.space.newlist_bytes(self.listview_bytes(w_dict))
def wrapkey(space, key):
- return space.wrap(key)
+ return space.newunicode(key)
## @jit.look_inside_iff(lambda self, w_dict:
## w_dict_unrolling_heuristic(w_dict))
@@ -1183,7 +1183,7 @@
unerase = staticmethod(unerase)
def wrap(self, unwrapped):
- return self.space.wrap(unwrapped)
+ return self.space.newint(unwrapped)
def unwrap(self, wrapped):
return self.space.int_w(wrapped)
@@ -1207,7 +1207,7 @@
return self.unerase(w_dict.dstorage).keys()
def wrapkey(space, key):
- return space.wrap(key)
+ return space.newint(key)
def w_keys(self, w_dict):
return self.space.newlist_int(self.listview_int(w_dict))
@@ -1219,7 +1219,7 @@
if isinstance(w_data, W_DictMultiObject): # optimization case only
update1_dict_dict(space, w_dict, w_data)
return
- w_method = space.findattr(w_data, space.wrap("keys"))
+ w_method = space.findattr(w_data, space.newtext("keys"))
if w_method is None:
# no 'keys' method, so we assume it is a sequence of pairs
data_w = space.listview(w_data)
@@ -1300,7 +1300,7 @@
return self
def descr_length_hint(self, space):
- return space.wrap(self.iteratorimplementation.length())
+ return space.newint(self.iteratorimplementation.length())
def descr_reduce(self, space):
"""
@@ -1417,8 +1417,8 @@
def descr_repr(self, space):
w_seq = space.call_function(space.w_list, self)
w_repr = space.repr(w_seq)
- return space.wrap("%s(%s)" % (space.type(self).getname(space),
- space.str_w(w_repr)))
+ return space.newtext("%s(%s)" % (space.type(self).getname(space),
+ space.str_w(w_repr)))
def descr_len(self, space):
return space.len(self.w_dict)
diff --git a/pypy/objspace/std/dictproxyobject.py b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -38,7 +38,7 @@
return space.str(self.w_mapping)
def descr_repr(self, space):
- return space.wrap("dict_proxy(%s)" %
+ return space.newtext("dict_proxy(%s)" %
(space.str_w(space.repr(self.w_mapping)),))
@unwrap_spec(w_default=WrappedDefault(None))
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -227,9 +227,9 @@
@unwrap_spec(kind=str)
def descr___getformat__(space, w_cls, kind):
if kind == "float":
- return space.wrap(_float_format)
+ return space.newtext(_float_format)
elif kind == "double":
- return space.wrap(_double_format)
+ return space.newtext(_double_format)
raise oefmt(space.w_ValueError, "only float and double are valid")
@staticmethod
@@ -372,7 +372,7 @@
i += 1
if i != length:
raise oefmt(space.w_ValueError, "invalid hex string")
- w_float = space.wrap(sign * value)
+ w_float = space.newfloat(sign * value)
return space.call_function(w_cls, w_float)
def _to_float(self, space, w_obj):
@@ -384,15 +384,15 @@
return W_FloatObject(space.float_w(w_obj))
def descr_repr(self, space):
- return space.wrap(float2string(self.floatval, 'r', 0))
+ return space.newtext(float2string(self.floatval, 'r', 0))
def descr_str(self, space):
- return space.wrap(float2string(self.floatval, 'g', DTSF_STR_PRECISION))
+ return space.newtext(float2string(self.floatval, 'g', DTSF_STR_PRECISION))
def descr_hash(self, space):
h = _hash_float(space, self.floatval)
h -= (h == -1)
- return space.wrap(h)
+ return space.newint(h)
def descr_format(self, space, w_spec):
return newformat.run_formatter(space, w_spec, "format_float", self)
@@ -584,7 +584,7 @@
return space.float(self)
def descr_get_imag(self, space):
- return space.wrap(0.0)
+ return space.newfloat(0.0)
def descr_conjugate(self, space):
return space.float(self)
@@ -593,7 +593,7 @@
v = self.floatval
if not rfloat.isfinite(v):
return space.w_False
- return space.wrap(math.floor(v) == v)
+ return space.newbool(math.floor(v) == v)
def descr_as_integer_ratio(self, space):
value = self.floatval
@@ -618,9 +618,9 @@
return self.descr_str(space)
if value == 0.0:
if copysign(1., value) == -1.:
- return space.wrap("-0x0.0p+0")
+ return space.newtext("-0x0.0p+0")
else:
- return space.wrap("0x0.0p+0")
+ return space.newtext("0x0.0p+0")
mant, exp = math.frexp(value)
shift = 1 - max(rfloat.DBL_MIN_EXP - exp, 0)
mant = math.ldexp(mant, shift)
@@ -641,9 +641,9 @@
exp = abs(exp)
s = ''.join(result)
if value < 0.0:
- return space.wrap("-0x%sp%s%d" % (s, sign, exp))
+ return space.newtext("-0x%sp%s%d" % (s, sign, exp))
else:
- return space.wrap("0x%sp%s%d" % (s, sign, exp))
+ return space.newtext("0x%sp%s%d" % (s, sign, exp))
W_FloatObject.typedef = TypeDef("float",
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -172,7 +172,7 @@
# floating-point division
a = float(x)
b = float(y)
- return space.wrap(a / b)
+ return space.newfloat(a / b)
def _mod(space, x, y):
@@ -190,8 +190,7 @@
raise oefmt(space.w_ZeroDivisionError, "integer divmod by zero")
# no overflow possible
m = x % y
- w = space.wrap
- return space.newtuple([w(z), w(m)])
+ return space.newtuple([space.newint(z), space.newint(m)])
def _divmod_ovf2small(space, x, y):
@@ -423,10 +422,10 @@
return space.newfloat(x)
def descr_oct(self, space):
- return space.wrap(oct(self.intval))
+ return space.newtext(oct(self.intval))
def descr_hex(self, space):
- return space.wrap(hex(self.intval))
+ return space.newtext(hex(self.intval))
def descr_getnewargs(self, space):
return space.newtuple([wrapint(space, self.intval)])
@@ -441,11 +440,11 @@
while val:
bits += 1
val >>= 1
- return space.wrap(bits)
+ return space.newint(bits)
def descr_repr(self, space):
res = str(self.intval)
- return space.wrap(res)
+ return space.newtext(res)
descr_str = func_with_new_name(descr_repr, 'descr_str')
def descr_format(self, space, w_format_spec):
@@ -478,7 +477,7 @@
result = _pow(space, x, y, z)
except (OverflowError, ValueError):
return _pow_ovf2long(space, x, y, w_modulus)
- return space.wrap(result)
+ return space.newint(result)
@unwrap_spec(w_modulus=WrappedDefault(None))
def descr_rpow(self, space, w_base, w_modulus=None):
diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -15,12 +15,12 @@
def getlength(self, space):
if self.w_seq is None:
- return space.wrap(0)
+ return space.newint(0)
index = self.index
w_length = space.len(self.w_seq)
- w_len = space.sub(w_length, space.wrap(index))
- if space.is_true(space.lt(w_len, space.wrap(0))):
- w_len = space.wrap(0)
+ w_len = space.sub(w_length, space.newint(index))
+ if space.is_true(space.lt(w_len, space.newint(0))):
+ w_len = space.newint(0)
return w_len
def descr_iter(self, space):
@@ -34,7 +34,7 @@
w_mod = space.getbuiltinmodule('_pickle_support')
mod = space.interp_w(MixedModule, w_mod)
new_inst = mod.get('seqiter_new')
- tup = [self.w_seq, space.wrap(self.index)]
+ tup = [self.w_seq, space.newint(self.index)]
return space.newtuple([new_inst, space.newtuple(tup)])
def descr_length_hint(self, space):
@@ -63,7 +63,7 @@
if self.w_seq is None:
raise OperationError(space.w_StopIteration, space.w_None)
try:
- w_item = space.getitem(self.w_seq, space.wrap(self.index))
+ w_item = space.getitem(self.w_seq, space.newint(self.index))
except OperationError as e:
self.w_seq = None
if not e.match(space, space.w_IndexError):
@@ -125,21 +125,21 @@
mod = space.interp_w(MixedModule, w_mod)
new_inst = mod.get('reverseseqiter_new')
w_seq = space.w_None if self.w_seq is None else self.w_seq
- tup = [w_seq, space.wrap(self.index)]
+ tup = [w_seq, space.newint(self.index)]
return space.newtuple([new_inst, space.newtuple(tup)])
def descr_length_hint(self, space):
length = self.index + 1
if self.w_seq is None or space.len_w(self.w_seq) < length:
length = 0
- return space.wrap(length)
+ return space.newint(length)
def descr_iter(self, space):
return self
def descr_next(self, space):
if self.index >= 0:
- w_index = space.wrap(self.index)
+ w_index = space.newint(self.index)
try:
w_item = space.getitem(self.w_seq, w_index)
except OperationError as e:
diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -11,7 +11,7 @@
def _wrapkey(space, key):
- return space.wrap(key)
+ return space.newtext(key)
class EmptyKwargsDictStrategy(EmptyDictStrategy):
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -438,7 +438,7 @@
def descr_repr(self, space):
if self.length() == 0:
- return space.wrap('[]')
+ return space.newtext('[]')
ec = space.getexecutioncontext()
w_currently_in_repr = ec._py_repr
if w_currently_in_repr is None:
@@ -643,7 +643,7 @@
if space.eq_w(self.getitem(i), w_value):
count += 1
i += 1
- return space.wrap(count)
+ return space.newint(count)
@unwrap_spec(index=int)
def descr_insert(self, space, index, w_value):
@@ -692,7 +692,7 @@
i = self.find(w_value, i, stop)
except ValueError:
raise oefmt(space.w_ValueError, "%R is not in list", w_value)
- return space.wrap(i)
+ return space.newint(i)
@unwrap_spec(reverse=bool)
def descr_sort(self, space, w_cmp=None, w_key=None, reverse=False):
@@ -1066,7 +1066,7 @@
w_list.lstorage = strategy.erase(items)
def wrap(self, intval):
- return self.space.wrap(intval)
+ return self.space.newint(intval)
def unwrap(self, w_int):
return self.space.int_w(w_int)
@@ -1654,7 +1654,7 @@
_none_value = 0
def wrap(self, intval):
- return self.space.wrap(intval)
+ return self.space.newint(intval)
def unwrap(self, w_int):
return self.space.int_w(w_int)
@@ -1750,7 +1750,7 @@
_none_value = 0.0
def wrap(self, floatval):
- return self.space.wrap(floatval)
+ return self.space.newfloat(floatval)
def unwrap(self, w_float):
return self.space.float_w(w_float)
@@ -1861,10 +1861,10 @@
def wrap(self, llval):
if longlong2float.is_int32_from_longlong_nan(llval):
intval = longlong2float.decode_int32_from_longlong_nan(llval)
- return self.space.wrap(intval)
+ return self.space.newint(intval)
else:
floatval = longlong2float.longlong2float(llval)
- return self.space.wrap(floatval)
+ return self.space.newfloat(floatval)
def unwrap(self, w_int_or_float):
if type(w_int_or_float) is W_IntObject:
@@ -1969,10 +1969,10 @@
_none_value = None
def wrap(self, stringval):
- return self.space.wrap(stringval)
+ return self.space.newbytes(stringval)
def unwrap(self, w_string):
- return self.space.str_w(w_string)
+ return self.space.bytes_w(w_string)
erase, unerase = rerased.new_erasing_pair("bytes")
erase = staticmethod(erase)
@@ -2001,7 +2001,7 @@
_none_value = None
def wrap(self, stringval):
- return self.space.wrap(stringval)
+ return self.space.newunicode(stringval)
def unwrap(self, w_string):
return self.space.unicode_w(w_string)
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -75,7 +75,7 @@
"""
bigint = space.bigint_w(self)
try:
- return space.wrap(bigint.bit_length())
+ return space.newint(bigint.bit_length())
except OverflowError:
raise oefmt(space.w_OverflowError, "too many digits in integer")
@@ -120,24 +120,24 @@
def descr_get_imag(self, space):
return space.newlong(0)
- def _make_descr_unaryop(opname):
+ def _make_descr_unaryop_text(opname):
op = getattr(rbigint, opname)
@func_renamer('descr_' + opname)
def descr_unaryop(self, space):
- return space.wrap(op(self.asbigint()))
+ return space.newtext(op(self.asbigint()))
descr_unaryop.__doc__ = 'x.__%s__(y) <==> %s(x, y)' % (opname, opname)
return descr_unaryop
- descr_repr = _make_descr_unaryop('repr')
- descr_str = _make_descr_unaryop('str')
+ descr_repr = _make_descr_unaryop_text('repr')
+ descr_str = _make_descr_unaryop_text('str')
def descr_hash(self, space):
h = self.asbigint().hash()
h -= (h == -1)
return space.newint(h)
- descr_oct = _make_descr_unaryop('oct')
- descr_hex = _make_descr_unaryop('hex')
+ descr_oct = _make_descr_unaryop_text('oct')
+ descr_hex = _make_descr_unaryop_text('hex')
def descr_pow(self, space, w_exponent, w_modulus=None):
"""x.__pow__(y[, z]) <==> pow(x, y[, z])"""
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -336,7 +336,7 @@
space = self.space
w_dict = obj.getdict(space)
try:
- space.delitem(w_dict, space.wrap(name))
+ space.delitem(w_dict, space.newtext(name))
except OperationError as ex:
if not ex.match(space, space.w_KeyError):
raise
@@ -401,7 +401,7 @@
def materialize_r_dict(self, space, obj, dict_w):
new_obj = self.back.materialize_r_dict(space, obj, dict_w)
if self.index == DICT:
- w_attr = space.wrap(self.name)
+ w_attr = space.newtext(self.name)
dict_w[w_attr] = obj._mapdict_read_storage(self.storageindex)
else:
self._copy_attr(obj, new_obj)
@@ -811,7 +811,7 @@
raise KeyError
key = curr.name
w_value = self.getitem_str(w_dict, key)
- w_key = self.space.wrap(key)
+ w_key = self.space.newtext(key)
self.delitem(w_dict, w_key)
return (w_key, w_value)
@@ -846,7 +846,7 @@
if curr_map:
self.curr_map = curr_map.back
attr = curr_map.name
- w_attr = self.space.wrap(attr)
+ w_attr = self.space.newtext(attr)
return w_attr
return None
@@ -887,7 +887,7 @@
if curr_map:
self.curr_map = curr_map.back
attr = curr_map.name
- w_attr = self.space.wrap(attr)
+ w_attr = self.space.newtext(attr)
return w_attr, self.w_obj.getdictvalue(self.space, attr)
return None, None
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -34,7 +34,7 @@
# xxx not the most efficient implementation
str1 = self.as_str()
str2 = w_other.as_str()
- return space.wrap(getattr(operator, name)(str1, str2))
+ return space.newbool(getattr(operator, name)(str1, str2))
try:
buf = space.buffer_w(w_other, space.BUF_CONTIG_RO)
@@ -45,7 +45,7 @@
else:
str1 = self.as_str()
str2 = buf.as_str()
- return space.wrap(getattr(operator, name)(str1, str2))
+ return space.newbool(getattr(operator, name)(str1, str2))
descr__cmp.func_name = name
return descr__cmp
@@ -63,13 +63,13 @@
return self.buf.getlength()
def descr_tobytes(self, space):
- return space.wrap(self.as_str())
+ return space.newbytes(self.as_str())
def descr_tolist(self, space):
buf = self.buf
result = []
for i in range(buf.getlength()):
- result.append(space.wrap(ord(buf.getitem(i))))
+ result.append(space.newint(ord(buf.getitem(i))))
return space.newlist(result)
def descr_getitem(self, space, w_index):
@@ -86,7 +86,7 @@
if step not in (0, 1):
raise oefmt(space.w_NotImplementedError, "")
if step == 0: # index only
- return space.wrap(self.buf.getitem(start))
+ return space.newbytes(self.buf.getitem(start))
else:
buf = SubBuffer(self.buf, start, size)
return W_MemoryView(buf)
@@ -116,16 +116,16 @@
self.buf.setslice(start, value.as_str())
def descr_len(self, space):
- return space.wrap(self.buf.getlength() / self.buf.getitemsize())
+ return space.newint(self.buf.getlength() / self.buf.getitemsize())
def w_get_format(self, space):
- return space.wrap(self.buf.getformat())
+ return space.newtext(self.buf.getformat())
def w_get_itemsize(self, space):
- return space.wrap(self.buf.getitemsize())
+ return space.newint(self.buf.getitemsize())
def w_get_ndim(self, space):
- return space.wrap(self.buf.getndim())
+ return space.newint(self.buf.getndim())
def w_is_readonly(self, space):
return space.newbool(bool(self.buf.readonly))
@@ -133,12 +133,12 @@
def w_get_shape(self, space):
if self.buf.getndim() == 0:
return space.w_None
- return space.newtuple([space.wrap(x) for x in self.buf.getshape()])
+ return space.newtuple([space.newint(x) for x in self.buf.getshape()])
def w_get_strides(self, space):
if self.buf.getndim() == 0:
return space.w_None
- return space.newtuple([space.wrap(x) for x in self.buf.getstrides()])
+ return space.newtuple([space.newint(x) for x in self.buf.getstrides()])
def w_get_suboffsets(self, space):
# I've never seen anyone filling this field
@@ -152,8 +152,8 @@
# report the error using the RPython-level internal repr of self.buf
msg = ("cannot find the underlying address of buffer that "
"is internally %r" % (self.buf,))
- raise OperationError(space.w_ValueError, space.wrap(msg))
- return space.wrap(rffi.cast(lltype.Signed, ptr))
+ raise OperationError(space.w_ValueError, space.newtext(msg))
+ return space.newint(rffi.cast(lltype.Signed, ptr))
W_MemoryView.typedef = TypeDef(
"memoryview",
diff --git a/pypy/objspace/std/noneobject.py b/pypy/objspace/std/noneobject.py
--- a/pypy/objspace/std/noneobject.py
+++ b/pypy/objspace/std/noneobject.py
@@ -11,7 +11,7 @@
return space.w_False
def descr_repr(self, space):
- return space.wrap('None')
+ return space.newtext('None')
W_NoneObject.w_None = W_NoneObject()
diff --git a/pypy/objspace/std/objectobject.py b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -170,25 +170,25 @@
def descr__reduce__(space, w_obj, proto=0):
if proto >= 2:
return reduce_2(space, w_obj)
- w_proto = space.wrap(proto)
+ w_proto = space.newint(proto)
return reduce_1(space, w_obj, w_proto)
@unwrap_spec(proto=int)
def descr__reduce_ex__(space, w_obj, proto=0):
- w_st_reduce = space.wrap('__reduce__')
+ w_st_reduce = space.newtext('__reduce__')
w_reduce = space.findattr(w_obj, w_st_reduce)
if w_reduce is not None:
- w_cls = space.getattr(w_obj, space.wrap('__class__'))
+ w_cls = space.getattr(w_obj, space.newtext('__class__'))
w_cls_reduce_meth = space.getattr(w_cls, w_st_reduce)
try:
- w_cls_reduce = space.getattr(w_cls_reduce_meth, space.wrap('im_func'))
+ w_cls_reduce = space.getattr(w_cls_reduce_meth, space.newtext('im_func'))
except OperationError as e:
# i.e. PyCFunction from cpyext
if not e.match(space, space.w_AttributeError):
raise
w_cls_reduce = space.w_None
w_objtype = space.w_object
- w_obj_dict = space.getattr(w_objtype, space.wrap('__dict__'))
+ w_obj_dict = space.getattr(w_objtype, space.newtext('__dict__'))
w_obj_reduce = space.getitem(w_obj_dict, w_st_reduce)
override = not space.is_w(w_cls_reduce, w_obj_reduce)
# print 'OVR', override, w_cls_reduce, w_obj_reduce
@@ -205,7 +205,7 @@
raise oefmt(space.w_TypeError, "format_spec must be a string")
if space.len_w(w_format_spec) > 0:
msg = "object.__format__ with a non-empty format string is deprecated"
- space.warn(space.wrap(msg), space.w_PendingDeprecationWarning)
+ space.warn(space.newtext(msg), space.w_PendingDeprecationWarning)
return space.format(w_as_str, w_format_spec)
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
@@ -325,9 +325,15 @@
return W_Buffer(w_obj)
def newbytes(self, s):
+ assert isinstance(s, str)
return W_BytesObject(s)
+ def newtext(self, s):
+ assert isinstance(s, str)
+ return W_BytesObject(s) # Python3 this is unicode
+
def newunicode(self, uni):
+ assert isinstance(uni, unicode)
return W_UnicodeObject(uni)
def type(self, w_obj):
diff --git a/pypy/objspace/std/proxyobject.py b/pypy/objspace/std/proxyobject.py
--- a/pypy/objspace/std/proxyobject.py
+++ b/pypy/objspace/std/proxyobject.py
@@ -12,7 +12,7 @@
def descr_call_mismatch(self, space, name, reqcls, args):
args_w = args.arguments_w[:]
- args_w[0] = space.wrap(name)
+ args_w[0] = space.newtext(name)
args = args.replace_arguments(args_w)
return space.call_args(self.w_controller, args)
@@ -26,8 +26,8 @@
def getdictvalue(self, space, attr):
try:
- return space.call_function(self.w_controller, space.wrap('__getattribute__'),
- space.wrap(attr))
+ return space.call_function(self.w_controller, space.newtext('__getattribute__'),
+ space.newtext(attr))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise
@@ -35,8 +35,8 @@
def setdictvalue(self, space, attr, w_value):
try:
- space.call_function(self.w_controller, space.wrap('__setattr__'),
- space.wrap(attr), w_value)
+ space.call_function(self.w_controller, space.newtext('__setattr__'),
+ space.newtext(attr), w_value)
return True
except OperationError as e:
if not e.match(space, space.w_AttributeError):
@@ -45,8 +45,8 @@
def deldictvalue(self, space, attr):
try:
- space.call_function(self.w_controller, space.wrap('__delattr__'),
- space.wrap(attr))
+ space.call_function(self.w_controller, space.newtext('__delattr__'),
+ space.newtext(attr))
return True
except OperationError as e:
if not e.match(space, space.w_AttributeError):
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -180,25 +180,25 @@
def descr_eq(self, space, w_other):
if isinstance(w_other, W_BaseSetObject):
- return space.wrap(self.equals(w_other))
+ return space.newbool(self.equals(w_other))
if not space.isinstance_w(w_other, space.w_set):
return space.w_NotImplemented
# XXX do not make new setobject here
w_other_as_set = self._newobj(space, w_other)
- return space.wrap(self.equals(w_other_as_set))
+ return space.newbool(self.equals(w_other_as_set))
def descr_ne(self, space, w_other):
if isinstance(w_other, W_BaseSetObject):
- return space.wrap(not self.equals(w_other))
+ return space.newbool(not self.equals(w_other))
if not space.isinstance_w(w_other, space.w_set):
return space.w_NotImplemented
# XXX this is not tested
w_other_as_set = self._newobj(space, w_other)
- return space.wrap(not self.equals(w_other_as_set))
+ return space.newbool(not self.equals(w_other_as_set))
# automatic registration of "lt(x, y)" as "not ge(y, x)" would not give the
# correct answer here!
@@ -217,7 +217,7 @@
if self.length() > w_other.length():
return space.w_False
- return space.wrap(self.issubset(w_other))
+ return space.newbool(self.issubset(w_other))
def descr_gt(self, space, w_other):
if not isinstance(w_other, W_BaseSetObject):
@@ -234,7 +234,7 @@
if self.length() < w_other.length():
return space.w_False
- return space.wrap(w_other.issubset(self))
+ return space.newbool(w_other.issubset(self))
def descr_len(self, space):
return space.newint(self.length())
@@ -354,12 +354,12 @@
if isinstance(w_other, W_BaseSetObject):
if self.length() > w_other.length():
return space.w_False
- return space.wrap(self.issubset(w_other))
+ return space.newbool(self.issubset(w_other))
w_other_as_set = self._newobj(space, w_other)
if self.length() > w_other_as_set.length():
return space.w_False
- return space.wrap(self.issubset(w_other_as_set))
+ return space.newbool(self.issubset(w_other_as_set))
def descr_issuperset(self, space, w_other):
"""Report whether this set contains another set."""
@@ -369,12 +369,12 @@
if isinstance(w_other, W_BaseSetObject):
if self.length() < w_other.length():
return space.w_False
- return space.wrap(w_other.issubset(self))
+ return space.newbool(w_other.issubset(self))
w_other_as_set = self._newobj(space, w_other)
if self.length() < w_other_as_set.length():
return space.w_False
- return space.wrap(w_other_as_set.issubset(self))
+ return space.newbool(w_other_as_set.issubset(self))
def descr_symmetric_difference(self, space, w_other):
"""Return the symmetric difference of two sets as a new set.
@@ -591,7 +591,7 @@
return None
# empty frozenset: base value 259
uid = (259 << IDTAG_SHIFT) | IDTAG_SPECIAL
- return space.wrap(uid)
+ return space.newint(uid)
def _newobj(self, space, w_iterable):
"""Make a new frozenset by taking ownership of 'w_iterable'."""
@@ -614,7 +614,7 @@
def descr_hash(self, space):
multi = r_uint(1822399083) + r_uint(1822399083) + 1
if self.hash != 0:
- return space.wrap(self.hash)
+ return space.newint(self.hash)
hash = r_uint(1927868237)
hash *= r_uint(self.length() + 1)
w_iterator = self.iter()
@@ -631,7 +631,7 @@
hash = intmask(hash)
self.hash = hash
- return space.wrap(hash)
+ return space.newint(hash)
W_FrozensetObject.typedef = TypeDef("frozenset",
__doc__ = """frozenset(iterable) --> frozenset object
@@ -1251,7 +1251,7 @@
return self.space.str_w(w_item)
def wrap(self, item):
- return self.space.wrap(item)
+ return self.space.newbytes(item)
def iter(self, w_set):
return BytesIteratorImplementation(self.space, self, w_set)
@@ -1290,7 +1290,7 @@
return self.space.unicode_w(w_item)
def wrap(self, item):
- return self.space.wrap(item)
+ return self.space.newunicode(item)
def iter(self, w_set):
return UnicodeIteratorImplementation(self.space, self, w_set)
@@ -1331,7 +1331,7 @@
return self.space.int_w(w_item)
def wrap(self, item):
- return self.space.wrap(item)
+ return self.space.newint(item)
def iter(self, w_set):
return IntegerIteratorImplementation(self.space, self, w_set)
@@ -1481,7 +1481,7 @@
def next_entry(self):
for key in self.iterator:
- return self.space.wrap(key)
+ return self.space.newbytes(key)
else:
return None
@@ -1494,7 +1494,7 @@
def next_entry(self):
for key in self.iterator:
- return self.space.wrap(key)
+ return self.space.newunicode(key)
else:
return None
@@ -1509,7 +1509,7 @@
def next_entry(self):
# note that this 'for' loop only runs once, at most
for key in self.iterator:
- return self.space.wrap(key)
+ return self.space.newint(key)
else:
return None
@@ -1520,8 +1520,8 @@
self.iterator = d.iterkeys()
def next_entry(self):
- for key in self.iterator:
- return self.space.wrap(key)
+ for w_key in self.iterator:
+ return w_key
else:
return None
@@ -1546,7 +1546,7 @@
self.iterimplementation = iterimplementation
def descr_length_hint(self, space):
- return space.wrap(self.iterimplementation.length())
+ return space.newint(self.iterimplementation.length())
def descr_iter(self, space):
return self
diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py
--- a/pypy/objspace/std/sliceobject.py
+++ b/pypy/objspace/std/sliceobject.py
@@ -105,7 +105,7 @@
return w_obj
def descr_repr(self, space):
- return space.wrap("slice(%s, %s, %s)" % (
+ return space.newtext("slice(%s, %s, %s)" % (
space.str_w(space.repr(self.w_start)),
space.str_w(space.repr(self.w_stop)),
space.str_w(space.repr(self.w_step))))
@@ -155,8 +155,8 @@
"""
length = space.getindex_w(w_length, space.w_OverflowError)
start, stop, step = self.indices3(space, length)
- return space.newtuple([space.wrap(start), space.wrap(stop),
- space.wrap(step)])
+ return space.newtuple([space.newint(start), space.newint(stop),
+ space.newint(step)])
def slicewprop(name):
diff --git a/pypy/objspace/std/specialisedtupleobject.py b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -14,6 +14,16 @@
def make_specialised_class(typetuple):
assert type(typetuple) == tuple
+ wraps = []
+ for typ in typetuple:
+ if typ == int:
+ wraps.append(lambda space, x: space.newint(x))
+ elif typ == float:
+ wraps.append(lambda space, x: space.newfloat(x))
+ elif typ == object:
+ wraps.append(lambda space, w_x: w_x)
+ else:
+ assert 0
typelen = len(typetuple)
iter_n = unrolling_iterable(range(typelen))
@@ -46,8 +56,7 @@
list_w = [None] * typelen
for i in iter_n:
value = getattr(self, 'value%s' % i)
- if typetuple[i] != object:
- value = self.space.wrap(value)
+ value = wraps[i](self.space, value)
list_w[i] = value
return list_w
@@ -78,7 +87,7 @@
z -= 1
mult += 82520 + z + z
x += 97531
- return space.wrap(intmask(x))
+ return space.newint(intmask(x))
def descr_eq(self, space, w_other):
if not isinstance(w_other, W_AbstractTupleObject):
@@ -89,8 +98,7 @@
for i in iter_n:
myval = getattr(self, 'value%s' % i)
otherval = w_other.getitem(space, i)
- if typetuple[i] != object:
- myval = space.wrap(myval)
+ myval = wraps[i](self.space, myval)
if not space.eq_w(myval, otherval):
return space.w_False
return space.w_True
@@ -119,8 +127,7 @@
for i in iter_n:
if index == i:
value = getattr(self, 'value%s' % i)
- if typetuple[i] != object:
- value = space.wrap(value)
+ value = wraps[i](self.space, value)
return value
raise oefmt(space.w_IndexError, "tuple index out of range")
@@ -163,10 +170,10 @@
# faster to move the decision out of the loop.
@specialize.arg(1)
-def _build_zipped_spec(space, Cls, lst1, lst2):
+def _build_zipped_spec(space, Cls, lst1, lst2, wrap1, wrap2):
length = min(len(lst1), len(lst2))
- return [Cls(space, space.wrap(lst1[i]),
- space.wrap(lst2[i])) for i in range(length)]
+ return [Cls(space, wrap1(lst1[i]),
+ wrap2(lst2[i])) for i in range(length)]
def _build_zipped_spec_oo(space, w_list1, w_list2):
strat1 = w_list1.strategy
@@ -192,15 +199,18 @@
if intlist1 is not None:
intlist2 = w_list2.getitems_int()
if intlist2 is not None:
- lst_w = _build_zipped_spec(space, Cls_ii, intlist1, intlist2)
+ lst_w = _build_zipped_spec(
+ space, Cls_ii, intlist1, intlist2,
+ space.newint, space.newint)
return space.newlist(lst_w)
else:
floatlist1 = w_list1.getitems_float()
if floatlist1 is not None:
floatlist2 = w_list2.getitems_float()
if floatlist2 is not None:
- lst_w = _build_zipped_spec(space, Cls_ff, floatlist1,
- floatlist2)
+ lst_w = _build_zipped_spec(
+ space, Cls_ff, floatlist1, floatlist2, space.newfloat,
+ space.newfloat)
return space.newlist(lst_w)
lst_w = _build_zipped_spec_oo(space, w_list1, w_list2)
diff --git a/pypy/objspace/std/strbufobject.py b/pypy/objspace/std/strbufobject.py
--- a/pypy/objspace/std/strbufobject.py
+++ b/pypy/objspace/std/strbufobject.py
@@ -44,7 +44,7 @@
return StringBuffer(self.force())
def descr_len(self, space):
- return space.wrap(self.length)
+ return space.newint(self.length)
def descr_add(self, space, w_other):
try:
diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -32,7 +32,7 @@
return c
def descr_len(self, space):
- return space.wrap(self._len())
+ return space.newint(self._len())
#def descr_iter(self, space):
# pass
@@ -163,7 +163,7 @@
res = count(value, buffer, start, end)
assert res >= 0
- return space.wrap(res)
+ return space.newint(res)
def descr_decode(self, space, w_encoding=None, w_errors=None):
from pypy.objspace.std.unicodeobject import (
@@ -239,7 +239,7 @@
if self._use_rstr_ops(space, w_sub):
res = value.find(self._op_val(space, w_sub), start, end)
- return space.wrap(res)
+ return space.newint(res)
from pypy.objspace.std.bytearrayobject import W_BytearrayObject
from pypy.objspace.std.bytesobject import W_BytesObject
@@ -251,14 +251,14 @@
buffer = _get_buffer(space, w_sub)
res = find(value, buffer, start, end)
- return space.wrap(res)
+ return space.newint(res)
def descr_rfind(self, space, w_sub, w_start=None, w_end=None):
(value, start, end) = self._convert_idx_params(space, w_start, w_end)
if self._use_rstr_ops(space, w_sub):
res = value.rfind(self._op_val(space, w_sub), start, end)
- return space.wrap(res)
+ return space.newint(res)
from pypy.objspace.std.bytearrayobject import W_BytearrayObject
from pypy.objspace.std.bytesobject import W_BytesObject
@@ -270,7 +270,7 @@
buffer = _get_buffer(space, w_sub)
res = rfind(value, buffer, start, end)
- return space.wrap(res)
+ return space.newint(res)
def descr_index(self, space, w_sub, w_start=None, w_end=None):
(value, start, end) = self._convert_idx_params(space, w_start, w_end)
@@ -290,7 +290,7 @@
if res < 0:
raise oefmt(space.w_ValueError,
"substring not found in string.index")
- return space.wrap(res)
+ return space.newint(res)
def descr_rindex(self, space, w_sub, w_start=None, w_end=None):
(value, start, end) = self._convert_idx_params(space, w_start, w_end)
@@ -310,7 +310,7 @@
if res < 0:
raise oefmt(space.w_ValueError,
"substring not found in string.rindex")
- return space.wrap(res)
+ return space.newint(res)
@specialize.arg(2)
def _is_generic(self, space, func_name):
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1098,6 +1098,7 @@
def str_w(self, string):
assert isinstance(string, str)
return string
+ bytes_w = str_w
def int_w(self, integer, allow_conversion=True):
assert isinstance(integer, int)
@@ -1105,6 +1106,7 @@
def wrap(self, obj):
return obj
+ newtext = newbytes = wrap
def isinstance_w(self, obj, klass):
return isinstance(obj, klass)
diff --git a/pypy/objspace/std/transparent.py b/pypy/objspace/std/transparent.py
--- a/pypy/objspace/std/transparent.py
+++ b/pypy/objspace/std/transparent.py
@@ -39,8 +39,8 @@
def setup(space):
"""Add proxy functions to the __pypy__ module."""
w___pypy__ = space.getbuiltinmodule("__pypy__")
- space.setattr(w___pypy__, space.wrap('tproxy'), space.wrap(app_proxy))
- space.setattr(w___pypy__, space.wrap('get_tproxy_controller'),
+ space.setattr(w___pypy__, space.newtext('tproxy'), space.wrap(app_proxy))
+ space.setattr(w___pypy__, space.newtext('get_tproxy_controller'),
space.wrap(app_proxy_controller))
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -53,7 +53,7 @@
return None
# empty tuple: base value 258
uid = (258 << IDTAG_SHIFT) | IDTAG_SPECIAL
- return space.wrap(uid)
+ return space.newint(uid)
def __repr__(self):
"""representation for debugging purposes"""
@@ -102,9 +102,9 @@
def descr_repr(self, space):
items = self.tolist()
if len(items) == 1:
- return space.wrap("(" + space.str_w(space.repr(items[0])) + ",)")
+ return space.newtext("(" + space.str_w(space.repr(items[0])) + ",)")
tmp = ", ".join([space.str_w(space.repr(item)) for item in items])
- return space.wrap("(" + tmp + ")")
+ return space.newtext("(" + tmp + ")")
def descr_hash(self, space):
raise NotImplementedError
@@ -216,7 +216,7 @@
for w_item in self.tolist():
if space.eq_w(w_item, w_obj):
count += 1
- return space.wrap(count)
+ return space.newint(count)
@unwrap_spec(w_start=WrappedDefault(0), w_stop=WrappedDefault(sys.maxint))
@jit.look_inside_iff(lambda self, _1, _2, _3, _4: _unroll_condition(self))
@@ -229,7 +229,7 @@
for i in range(start, min(stop, length)):
w_item = self.tolist()[i]
if space.eq_w(w_item, w_obj):
- return space.wrap(i)
+ return space.newint(i)
raise oefmt(space.w_ValueError, "tuple.index(x): x not in tuple")
W_AbstractTupleObject.typedef = TypeDef(
@@ -300,7 +300,7 @@
z -= 1
mult += 82520 + z + z
x += 97531
- return space.wrap(intmask(x))
+ return space.newint(intmask(x))
def _descr_hash_jitdriver(self, space):
mult = 1000003
@@ -314,7 +314,7 @@
z -= 1
mult += 82520 + z + z
x += 97531
- return space.wrap(intmask(x))
+ return space.newint(intmask(x))
def descr_eq(self, space, w_other):
if not isinstance(w_other, W_AbstractTupleObject):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -34,7 +34,7 @@
self.intvalue = intvalue
def unwrap_cell(self, space):
- return space.wrap(self.intvalue)
+ return space.newint(self.intvalue)
def __repr__(self):
return "<IntMutableCell: %s>" % (self.intvalue, )
@@ -337,7 +337,7 @@
if name == "__del__" and name not in self.dict_w:
msg = ("a __del__ method added to an existing type will not be "
"called")
- space.warn(space.wrap(msg), space.w_RuntimeWarning)
+ space.warn(space.newtext(msg), space.w_RuntimeWarning)
version_tag = self.version_tag()
if version_tag is not None:
w_curr = self._pure_getdictvalue_no_unwrapping(
@@ -533,7 +533,7 @@
mod = self.name[:dot]
else:
mod = "__builtin__"
- return space.wrap(mod)
+ return space.newtext(mod)
def getname(self, space):
if self.is_heaptype():
@@ -644,9 +644,9 @@
else:
kind = 'class'
if mod is not None and mod != '__builtin__':
- return space.wrap("<%s '%s.%s'>" % (kind, mod, self.getname(space)))
+ return space.newtext("<%s '%s.%s'>" % (kind, mod, self.getname(space)))
else:
- return space.wrap("<%s '%s'>" % (kind, self.name))
+ return space.newtext("<%s '%s'>" % (kind, self.name))
def descr_getattribute(self, space, w_name):
name = space.str_w(w_name)
@@ -724,8 +724,8 @@
" bases")
if not space.is_w(w_winner, w_typetype):
- newfunc = space.getattr(w_winner, space.wrap('__new__'))
- if not space.is_w(newfunc, space.getattr(space.w_type, space.wrap('__new__'))):
+ newfunc = space.getattr(w_winner, space.newtext('__new__'))
+ if not space.is_w(newfunc, space.getattr(space.w_type, space.newtext('__new__'))):
return space.call_function(newfunc, w_winner, w_name, w_bases, w_dict)
w_typetype = w_winner
@@ -763,13 +763,13 @@
def _check(space, w_type, msg="descriptor is for 'type'"):
if not isinstance(w_type, W_TypeObject):
- raise OperationError(space.w_TypeError, space.wrap(msg))
+ raise OperationError(space.w_TypeError, space.newtext(msg))
return w_type
def descr_get__name__(space, w_type):
w_type = _check(space, w_type)
- return space.wrap(w_type.getname(space))
+ return space.newtext(w_type.getname(space))
def descr_set__name__(space, w_type, w_value):
w_type = _check(space, w_type)
@@ -870,7 +870,7 @@
def descr__doc(space, w_type):
if space.is_w(w_type, space.w_type):
- return space.wrap("""type(object) -> the object's type
+ return space.newtext("""type(object) -> the object's type
type(name, bases, dict) -> a new type""")
w_type = _check(space, w_type)
if not w_type.is_heaptype():
@@ -894,7 +894,7 @@
flags |= _CPYTYPE
if w_type.flag_abstract:
flags |= _ABSTRACT
- return space.wrap(flags)
+ return space.newint(flags)
def descr_get__module(space, w_type):
w_type = _check(space, w_type)
@@ -1195,7 +1195,7 @@
caller = space.getexecutioncontext().gettopframe_nohidden()
if caller is not None:
w_globals = caller.get_w_globals()
- w_name = space.finditem(w_globals, space.wrap('__name__'))
+ w_name = space.finditem(w_globals, space.newtext('__name__'))
if w_name is not None:
w_self.dict_w['__module__'] = w_name
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
@@ -72,7 +72,7 @@
else:
base = 257 # empty unicode string: base value 257
uid = (base << IDTAG_SHIFT) | IDTAG_SPECIAL
- return space.wrap(uid)
+ return space.newint(uid)
def str_w(self, space):
return space.str_w(space.str(self))
@@ -101,7 +101,7 @@
raise oefmt(space.w_TypeError,
"ord() expected a character, but string of length %d "
"found", len(self._value))
- return space.wrap(ord(self._value[0]))
+ return space.newint(ord(self._value[0]))
def _new(self, value):
return W_UnicodeObject(value)
@@ -201,7 +201,7 @@
is_precisely_unicode = space.is_w(space.type(w_obj), space.w_unicode)
if (is_precisely_unicode or
(space.isinstance_w(w_obj, space.w_unicode) and
- space.findattr(w_obj, space.wrap('__unicode__')) is None)):
+ space.findattr(w_obj, space.newtext('__unicode__')) is None)):
if encoding is not None or errors is not None:
raise oefmt(space.w_TypeError,
"decoding Unicode is not supported")
@@ -227,14 +227,14 @@
chars = self._value
size = len(chars)
s = _repr_function(chars, size, "strict")
- return space.wrap(s)
+ return space.newtext(s)
def descr_str(self, space):
return encode_object(space, self, None, None)
def descr_hash(self, space):
x = compute_hash(self._value)
- return space.wrap(x)
+ return space.newint(x)
def descr_eq(self, space, w_other):
try:
@@ -247,7 +247,7 @@
msg = ("Unicode equal comparison failed to convert both "
"arguments to Unicode - interpreting them as being "
"unequal")
- space.warn(space.wrap(msg), space.w_UnicodeWarning)
+ space.warn(space.newtext(msg), space.w_UnicodeWarning)
return space.w_False
raise
return space.newbool(res)
@@ -263,7 +263,7 @@
msg = ("Unicode unequal comparison failed to convert both "
"arguments to Unicode - interpreting them as being "
"unequal")
- space.warn(space.wrap(msg), space.w_UnicodeWarning)
+ space.warn(space.newtext(msg), space.w_UnicodeWarning)
return space.w_True
raise
return space.newbool(res)
@@ -323,11 +323,11 @@
selfvalue = self._value
w_sys = space.getbuiltinmodule('sys')
maxunicode = space.int_w(space.getattr(w_sys,
- space.wrap("maxunicode")))
+ space.newtext("maxunicode")))
result = []
for unichar in selfvalue:
try:
- w_newval = space.getitem(w_table, space.wrap(ord(unichar)))
+ w_newval = space.getitem(w_table, space.newint(ord(unichar)))
except OperationError as e:
if e.match(space, space.w_LookupError):
result.append(unichar)
@@ -361,8 +361,8 @@
l = space.listview_unicode(w_list)
if l is not None:
if len(l) == 1:
- return space.wrap(l[0])
- return space.wrap(self._val(space).join(l))
+ return space.newunicode(l[0])
+ return space.newunicode(self._val(space).join(l))
return self._StringMethods_descr_join(space, w_list)
More information about the pypy-commit
mailing list