[pypy-commit] pypy py3.5-newtext: hg merge 1bddaf521a03
arigo
pypy.commits at gmail.com
Mon Feb 13 13:14:55 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-newtext
Changeset: r90101:f73ab0b44844
Date: 2017-02-13 19:13 +0100
http://bitbucket.org/pypy/pypy/changeset/f73ab0b44844/
Log: hg merge 1bddaf521a03
diff --git a/pypy/module/__builtin__/__init__.py b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -87,7 +87,7 @@
# this is obscure and slow
space = self.space
try:
- w_builtin = space.getitem(w_globals, space.wrap('__builtins__'))
+ w_builtin = space.getitem(w_globals, space.newtext('__builtins__'))
except OperationError as e:
if not e.match(space, space.w_KeyError):
raise
@@ -100,7 +100,7 @@
return w_builtin
# no builtin! make a default one. Give them None, at least.
builtin = module.Module(space, None)
- space.setitem(builtin.w_dict, space.wrap('None'), space.w_None)
+ space.setitem(builtin.w_dict, space.newtext('None'), space.w_None)
return builtin
def setup_after_space_initialization(self):
diff --git a/pypy/module/__builtin__/abstractinst.py b/pypy/module/__builtin__/abstractinst.py
--- a/pypy/module/__builtin__/abstractinst.py
+++ b/pypy/module/__builtin__/abstractinst.py
@@ -17,7 +17,7 @@
no __bases__ or if cls.__bases__ is not a tuple.
"""
try:
- w_bases = space.getattr(w_cls, space.wrap('__bases__'))
+ w_bases = space.getattr(w_cls, space.newtext('__bases__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise # propagate other errors
@@ -32,12 +32,12 @@
def check_class(space, w_obj, msg):
if not abstract_isclass_w(space, w_obj):
- raise OperationError(space.w_TypeError, space.wrap(msg))
+ raise OperationError(space.w_TypeError, space.newtext(msg))
def abstract_getclass(space, w_obj):
try:
- return space.getattr(w_obj, space.wrap('__class__'))
+ return space.getattr(w_obj, space.newtext('__class__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise # propagate other errors
@@ -55,7 +55,7 @@
check_class(space, w_cls, "isinstance() arg 2 must be a class, type,"
" or tuple of classes and types")
try:
- w_abstractclass = space.getattr(w_inst, space.wrap('__class__'))
+ w_abstractclass = space.getattr(w_inst, space.newtext('__class__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise # propagate other errors
@@ -70,7 +70,7 @@
if space.isinstance_w(w_inst, w_type):
return True
try:
- w_abstractclass = space.getattr(w_inst, space.wrap('__class__'))
+ w_abstractclass = space.getattr(w_inst, space.newtext('__class__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise # propagate other errors
@@ -212,14 +212,14 @@
another class. When using a tuple as the second argument, check whether
'cls' is a subclass of any of the classes listed in the tuple."""
result = abstract_issubclass_w(space, w_cls, w_klass_or_tuple, True)
- return space.wrap(result)
+ return space.newbool(result)
def isinstance(space, w_obj, w_klass_or_tuple):
"""Check whether an object is an instance of a class (or of a subclass
thereof). When using a tuple as the second argument, check whether 'obj'
is an instance of any of the classes listed in the tuple."""
result = abstract_isinstance_w(space, w_obj, w_klass_or_tuple, True)
- return space.wrap(result)
+ return space.newbool(result)
# avoid namespace pollution
app_issubclass = issubclass; del issubclass
diff --git a/pypy/module/__builtin__/compiling.py b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -45,9 +45,8 @@
if space.isinstance_w(w_source, space.gettypeobject(ast.W_AST.typedef)):
ast_node = ast.mod.from_object(space, w_source)
ec.compiler.validate_ast(ast_node)
- code = ec.compiler.compile_ast(ast_node, filename, mode, flags,
+ return ec.compiler.compile_ast(ast_node, filename, mode, flags,
optimize=optimize)
- return space.wrap(code)
flags |= consts.PyCF_SOURCE_IS_UTF8
source, flags = source_as_str(space, w_source, 'compile',
@@ -57,9 +56,8 @@
node = ec.compiler.compile_to_ast(source, filename, mode, flags)
return node.to_object(space)
else:
- code = ec.compiler.compile(source, filename, mode, flags,
+ return ec.compiler.compile(source, filename, mode, flags,
optimize=optimize)
- return space.wrap(code)
def eval(space, w_prog, w_globals=None, w_locals=None):
@@ -113,7 +111,7 @@
w_meta = _calculate_metaclass(space, w_meta, bases_w)
try:
- w_prep = space.getattr(w_meta, space.wrap("__prepare__"))
+ w_prep = space.getattr(w_meta, space.newtext("__prepare__"))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise
diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -33,7 +33,7 @@
objtype_name = u"<%s object>" % self.w_objtype.getname(space)
else:
objtype_name = u'NULL'
- return space.wrap(u"<super: <class '%s'>, %s>" % (
+ return space.newunicode(u"<super: <class '%s'>, %s>" % (
self.w_starttype.getname(space), objtype_name))
def get(self, space, w_obj, w_type=None):
@@ -122,7 +122,7 @@
return w_objtype
try:
- w_type = space.getattr(w_obj_or_type, space.wrap('__class__'))
+ w_type = space.getattr(w_obj_or_type, space.newtext('__class__'))
except OperationError as e:
if not e.match(space, space.w_AttributeError):
raise
@@ -175,12 +175,12 @@
# our __doc__ comes from the getter if we don't have an explicit one
if (space.is_w(self.w_doc, space.w_None) and
not space.is_w(self.w_fget, space.w_None)):
- w_getter_doc = space.findattr(self.w_fget, space.wrap('__doc__'))
+ w_getter_doc = space.findattr(self.w_fget, space.newtext('__doc__'))
if w_getter_doc is not None:
if type(self) is W_Property:
self.w_doc = w_getter_doc
else:
- space.setattr(self, space.wrap('__doc__'), w_getter_doc)
+ space.setattr(self, space.newtext('__doc__'), w_getter_doc)
self.getter_doc = True
def get(self, space, w_obj, w_objtype=None):
diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -251,10 +251,10 @@
self = space.allocate_instance(W_Enumerate, w_subtype)
self.__init__(w_iter, start, w_start)
- return space.wrap(self)
+ return self
def descr___iter__(self, space):
- return space.wrap(self)
+ return self
def descr_next(self, space):
from pypy.objspace.std.listobject import W_ListObject
@@ -276,14 +276,14 @@
try:
newval = rarithmetic.ovfcheck(index + 1)
except OverflowError:
- w_index = space.wrap(index)
- self.w_index = space.add(w_index, space.wrap(1))
+ w_index = space.newint(index)
+ self.w_index = space.add(w_index, space.newint(1))
self.index = -1
else:
self.index = newval
- w_index = space.wrap(index)
+ w_index = space.newint(index)
else:
- self.w_index = space.add(w_index, space.wrap(1))
+ self.w_index = space.add(w_index, space.newint(1))
if w_item is None:
w_item = space.next(self.w_iter_or_list)
return space.newtuple([w_index, w_item])
@@ -291,7 +291,7 @@
def descr___reduce__(self, space):
w_index = self.w_index
if w_index is None:
- w_index = space.wrap(self.index)
+ w_index = space.newint(self.index)
return space.newtuple([space.type(self),
space.newtuple([self.w_iter_or_list, w_index])])
@@ -302,7 +302,7 @@
w_index = None
else:
index = -1
- return space.wrap(W_Enumerate(w_iter_or_list, index, w_index))
+ return W_Enumerate(w_iter_or_list, index, w_index)
W_Enumerate.typedef = TypeDef("enumerate",
__new__=interp2app(W_Enumerate.descr___new__),
@@ -333,10 +333,10 @@
"argument to reversed() must be a sequence")
self = space.allocate_instance(W_ReversedIterator, w_subtype)
self.__init__(space, w_sequence)
- return space.wrap(self)
+ return self
def descr___iter__(self, space):
- return space.wrap(self)
+ return self
def descr_length_hint(self, space):
# bah, there is even a CPython test that checks that this
@@ -347,11 +347,11 @@
rem_length = self.remaining + 1
if rem_length <= total_length:
res = rem_length
- return space.wrap(res)
+ return space.newint(res)
def descr_next(self, space):
if self.remaining >= 0:
- w_index = space.wrap(self.remaining)
+ w_index = space.newint(self.remaining)
try:
w_item = space.getitem(self.w_sequence, w_index)
except OperationError as e:
@@ -373,7 +373,7 @@
def descr___reduce__(self, space):
if self.w_sequence:
- w_state = space.wrap(self.remaining)
+ w_state = space.newint(self.remaining)
return space.newtuple([
space.type(self),
space.newtuple([self.w_sequence]),
@@ -413,7 +413,7 @@
w_start = space.index(w_start)
promote_step = False
if space.is_none(w_step): # no step argument provided
- w_step = space.wrap(1)
+ w_step = space.newint(1)
promote_step = True
if space.is_none(w_stop): # only 1 argument provided
w_start, w_stop = space.newint(0), w_start
@@ -431,15 +431,15 @@
w_length = compute_range_length(space, w_start, w_stop, w_step)
obj = space.allocate_instance(W_Range, w_subtype)
W_Range.__init__(obj, w_start, w_stop, w_step, w_length, promote_step)
- return space.wrap(obj)
+ return obj
def descr_repr(self, space):
if not space.is_true(space.eq(self.w_step, space.newint(1))):
- return space.mod(space.wrap("range(%d, %d, %d)"),
+ return space.mod(space.newtext("range(%d, %d, %d)"),
space.newtuple([self.w_start, self.w_stop,
self.w_step]))
else:
- return space.mod(space.wrap("range(%d, %d)"),
+ return space.mod(space.newtext("range(%d, %d)"),
space.newtuple([self.w_start, self.w_stop]))
def descr_len(self):
@@ -473,7 +473,7 @@
w_length = compute_range_length(space, w_substart, w_substop, w_substep)
obj = W_Range(w_substart, w_substop, w_substep, w_length)
- return space.wrap(obj)
+ return obj
def descr_getitem(self, space, w_index):
# Cannot use the usual space.decode_index methods, because
@@ -504,8 +504,8 @@
self.w_start,
space.mul(space.sub(self.w_length, space.newint(1)),
self.w_step))
- return space.wrap(W_LongRangeIterator(
- space, w_lastitem, space.neg(self.w_step), self.w_length))
+ return W_LongRangeIterator(
+ space, w_lastitem, space.neg(self.w_step), self.w_length)
def descr_reduce(self, space):
return space.newtuple(
@@ -564,18 +564,18 @@
return space.w_NotImplemented
if not space.eq_w(self.w_length, w_other.w_length):
return space.w_False
- if space.eq_w(self.w_length, space.wrap(0)):
+ if space.eq_w(self.w_length, space.newint(0)):
return space.w_True
if not space.eq_w(self.w_start, w_other.w_start):
return space.w_False
- if space.eq_w(self.w_length, space.wrap(1)):
+ if space.eq_w(self.w_length, space.newint(1)):
return space.w_True
return space.eq(self.w_step, w_other.w_step)
def descr_hash(self, space):
- if space.eq_w(self.w_length, space.wrap(0)):
+ if space.eq_w(self.w_length, space.newint(0)):
w_tup = space.newtuple([self.w_length, space.w_None, space.w_None])
- elif space.eq_w(self.w_length, space.wrap(1)):
+ elif space.eq_w(self.w_length, space.newint(1)):
w_tup = space.newtuple([self.w_length, self.w_start, space.w_None])
else:
w_tup = space.newtuple([self.w_length, self.w_start, self.w_step])
@@ -605,7 +605,7 @@
class W_AbstractRangeIterator(W_Root):
def descr_iter(self, space):
- return space.wrap(self)
+ return self
def descr_len(self, space):
raise NotImplementedError
@@ -662,7 +662,7 @@
item = self.current
self.current = item + self.step
self.remaining -= 1
- return space.wrap(item)
+ return space.newint(item)
raise OperationError(space.w_StopIteration, space.w_None)
def descr_len(self, space):
@@ -673,14 +673,13 @@
w_mod = space.getbuiltinmodule('_pickle_support')
mod = space.interp_w(MixedModule, w_mod)
new_inst = mod.get('intrangeiter_new')
- w = space.wrap
nt = space.newtuple
- tup = [w(self.current), self.get_remaining(space), w(self.step)]
+ tup = [space.newint(self.current), self.get_remaining(space), space.newint(self.step)]
return nt([new_inst, nt(tup)])
def get_remaining(self, space):
- return space.wrap(self.remaining)
+ return space.newint(self.remaining)
class W_IntRangeStepOneIterator(W_IntRangeIterator):
@@ -695,11 +694,11 @@
if self.current < self.stop:
item = self.current
self.current = item + 1
- return space.wrap(item)
+ return space.newint(item)
raise OperationError(space.w_StopIteration, space.w_None)
def get_remaining(self, space):
- return space.wrap(self.stop - self.current)
+ return space.newint(self.stop - self.current)
W_AbstractRangeIterator.typedef = TypeDef("rangeiterator",
@@ -739,7 +738,7 @@
self.iterators_w = iterators_w
def iter_w(self):
- return self.space.wrap(self)
+ return self
def next_w(self):
# common case: 1 or 2 arguments
@@ -764,7 +763,7 @@
def descr_reduce(self, space):
w_map = space.getattr(space.getbuiltinmodule('builtins'),
- space.wrap('map'))
+ space.newtext('map'))
args_w = [self.w_fun] + self.iterators_w
return space.newtuple([w_map, space.newtuple(args_w)])
@@ -775,7 +774,7 @@
"map() must have at least two arguments")
r = space.allocate_instance(W_Map, w_subtype)
r.__init__(space, w_fun, args_w)
- return space.wrap(r)
+ return r
W_Map.typedef = TypeDef(
'map',
@@ -800,7 +799,7 @@
self.iterable = space.iter(w_iterable)
def iter_w(self):
- return self.space.wrap(self)
+ return self
def next_w(self):
while True:
@@ -815,7 +814,7 @@
def descr_reduce(self, space):
w_filter = space.getattr(space.getbuiltinmodule('builtins'),
- space.wrap('filter'))
+ space.newtext('filter'))
args_w = [space.w_None if self.no_predicate else self.w_predicate,
self.iterable]
return space.newtuple([w_filter, space.newtuple(args_w)])
@@ -824,7 +823,7 @@
def W_Filter___new__(space, w_subtype, w_predicate, w_iterable):
r = space.allocate_instance(W_Filter, w_subtype)
r.__init__(space, w_predicate, w_iterable)
- return space.wrap(r)
+ return r
W_Filter.typedef = TypeDef(
'filter',
@@ -850,14 +849,14 @@
def descr_reduce(self, space):
w_zip = space.getattr(space.getbuiltinmodule('builtins'),
- space.wrap('zip'))
+ space.newtext('zip'))
return space.newtuple([w_zip, space.newtuple(self.iterators_w)])
def W_Zip___new__(space, w_subtype, args_w):
r = space.allocate_instance(W_Zip, w_subtype)
r.__init__(space, None, args_w)
- return space.wrap(r)
+ return r
W_Zip.typedef = TypeDef(
'zip',
diff --git a/pypy/module/__builtin__/operation.py b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -29,7 +29,7 @@
c = UNICHR(code)
except ValueError:
raise oefmt(space.w_ValueError, "chr() arg out of range")
- return space.wrap(c)
+ return space.newunicode(c)
def len(space, w_obj):
"len(object) -> integer\n\nReturn the number of items of a sequence or mapping."
@@ -44,8 +44,8 @@
# Note that if w_name is already an exact string it must be returned
# unmodified (and not e.g. unwrapped-rewrapped).
if not space.is_w(space.type(w_name), space.w_text):
- name = space.unicode_w(w_name) # typecheck
- w_name = space.wrap(name) # rewrap as a real string
+ name = space.text_w(w_name) # typecheck
+ w_name = space.newtext(name) # rewrap as a real string
return w_name
def delattr(space, w_object, w_name):
More information about the pypy-commit
mailing list