Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88510:df80a32ac30f
Date: 2016-11-16 14:11 +0100
http://bitbucket.org/pypy/pypy/changeset/df80a32ac30f/

Log:    various fixes

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -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.newtext(%r)' % (options)
+        wrapstr = 'space.wrap(%r)' % (options) # import time
         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/astcompiler/misc.py 
b/pypy/interpreter/astcompiler/misc.py
--- a/pypy/interpreter/astcompiler/misc.py
+++ b/pypy/interpreter/astcompiler/misc.py
@@ -19,10 +19,10 @@
 
     If the user has set this warning to raise an error, a SyntaxError will be
     raised."""
-    w_msg = space.wrap(msg)
+    w_msg = space.newtext(msg)
     w_filename = space.wrap(fn)
-    w_lineno = space.wrap(lineno)
-    w_offset = space.wrap(offset)
+    w_lineno = space.newint(lineno)
+    w_offset = space.newint(offset)
     _emit_syntax_warning(space, w_msg, w_filename, w_lineno, w_offset)
 
 
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -425,7 +425,6 @@
     @jit.dont_look_inside
     def _reduce_state(self, space):
         from pypy.module._pickle_support import maker # helper fns
-        w = space.wrap
         nt = space.newtuple
 
         if self.get_w_f_trace() is None:
@@ -447,26 +446,26 @@
 
         d = self.getorcreatedebug()
         tup_state = [
-            w(self.f_backref()),
-            w(self.get_builtin()),
-            w(self.pycode),
+            self.f_backref(),
+            self.get_builtin(),
+            self.pycode,
             w_locals_cells_stack,
             w_blockstack,
             w_exc_value, # last_exception
             w_tb,        #
             self.get_w_globals(),
-            w(self.last_instr),
-            w(self.frame_finished_execution),
-            w(f_lineno),
+            space.newint(self.last_instr),
+            space.newbool(self.frame_finished_execution),
+            space.newint(f_lineno),
             space.w_None,           #XXX placeholder for f_locals
 
             #f_restricted requires no additional data!
             space.w_None,
 
-            w(d.instr_lb),
-            w(d.instr_ub),
-            w(d.instr_prev_plus_one),
-            w(self.valuestackdepth),
+            space.newint(d.instr_lb),
+            space.newint(d.instr_ub),
+            space.newint(d.instr_prev_plus_one),
+            space.newint(self.valuestackdepth),
             ]
         return nt(tup_state)
 
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -65,7 +65,7 @@
         # decode input (with the eventual \r from a previous pass)
         if not space.is_w(self.w_decoder, space.w_None):
             w_output = space.call_method(self.w_decoder, "decode",
-                                         w_input, space.newbool(final))
+                                         w_input, space.newbool(bool(final)))
         else:
             w_output = w_input
 
diff --git a/pypy/module/micronumpy/__init__.py 
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -48,7 +48,7 @@
 class UMathModule(MixedModule):
     appleveldefs = {}
     interpleveldefs = {
-        'FLOATING_POINT_SUPPORT': 'space.wrap(1)',
+        'FLOATING_POINT_SUPPORT': 'space.newint(1)',
         'frompyfunc': 'ufuncs.frompyfunc',
         }
     # ufuncs
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -68,7 +68,7 @@
         scalar = multiarray.get("scalar")
 
         ret = space.newtuple([scalar, space.newtuple(
-            [space.wrap(self._get_dtype(space)), space.wrap(self.raw_str())])])
+            [self._get_dtype(space), space.newtext(self.raw_str())])])
         return ret
 
 
diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -194,6 +194,9 @@
         return StringObject(obj)
     newbytes = newtext
 
+    def newunicode(self, obj):
+        raise NotImplementedError
+
     def newlist(self, items):
         return ListObject(items)
 
@@ -665,7 +668,7 @@
 
     def execute(self, interp):
         w_list = interp.space.newlist(
-            [interp.space.wrap(float(i)) for i in range(self.v)]
+            [interp.space.newfloat(float(i)) for i in range(self.v)]
         )
         dtype = get_dtype_cache(interp.space).w_float64dtype
         return array(interp.space, w_list, w_dtype=dtype, w_order=None)
@@ -832,7 +835,7 @@
                 w_res = arr.descr_take(interp.space, arg)
             elif self.name == "searchsorted":
                 w_res = arr.descr_searchsorted(interp.space, arg,
-                                               interp.space.wrap('left'))
+                                               interp.space.newtext('left'))
             else:
                 assert False # unreachable code
         elif self.name in THREE_ARG_FUNCTIONS:
diff --git a/pypy/module/micronumpy/concrete.py 
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -303,7 +303,7 @@
                 copy = True
             w_ret = new_view(space, orig_arr, chunks)
             if copy:
-                w_ret = w_ret.descr_copy(space, space.wrap(w_ret.get_order()))
+                w_ret = w_ret.descr_copy(space, 
space.newint(w_ret.get_order()))
             return w_ret
 
     def descr_setitem(self, space, orig_arr, w_index, w_value):
diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -281,7 +281,7 @@
                     substr = ["(", space.str_w(space.str(
                         subdtype.subdtype.descr_get_descr(space, 
style='descr_subdtype'))),
                         ', ',
-                        space.str_w(space.repr(space.newtuple([space.wrap(s) 
for s in subdtype.shape]))),
+                        space.str_w(space.repr(space.newtuple([space.newint(s) 
for s in subdtype.shape]))),
                         "),"]
                 else:
                     substr = ["'", subdtype.get_str(ignore=''), "',"]
@@ -366,12 +366,12 @@
         return space.newbool(self.is_native())
 
     def descr_get_base(self, space):
-        return space.wrap(self.base)
+        return self.base
 
     def descr_get_subdtype(self, space):
         if self.subdtype is None:
             return space.w_None
-        return space.newtuple([space.wrap(self.subdtype),
+        return space.newtuple([self.subdtype,
                                self.descr_get_shape(space)])
 
     def descr_get_shape(self, space):
@@ -594,7 +594,7 @@
 
     def runpack_str(self, space, s):
         if self.is_str_or_unicode():
-            return self.coerce(space, space.wrap(s))
+            return self.coerce(space, space.newbytes(s))
         return self.itemtype.runpack_str(space, s, self.is_native())
 
     def store(self, arr, i, offset, value):
@@ -943,8 +943,8 @@
             raise
         # handle only simple cases for testing
         if space.isinstance_w(w_spec, space.w_str):
-            spec = [s.strip() for s in space.str_w(w_spec).split(',')]
-            w_lst = space.newlist([space.wrap(s) for s in spec]) 
+            spec = [s.strip() for s in space.text_w(w_spec).split(',')]
+            w_lst = space.newlist([space.newtext(s) for s in spec]) 
     if not space.isinstance_w(w_lst, space.w_list) or space.len_w(w_lst) < 1:
         raise oefmt(space.w_RuntimeError,
                     "_commastring is not returning a list with len >= 1")
@@ -1066,9 +1066,9 @@
     if space.isinstance_w(w_dtype, w_subtype):
         return w_dtype
     if space.isinstance_w(w_dtype, space.w_unicode):
-        w_dtype = space.wrap(space.str_w(w_dtype))  # may raise if invalid
-    if space.isinstance_w(w_dtype, space.w_str):
-        name = space.str_w(w_dtype)
+        w_dtype = space.newbytes(space.text_w(w_dtype))  # may raise if invalid
+    if space.isinstance_w(w_dtype, space.w_bytes):
+        name = space.bytes_w(w_dtype)
         if _check_for_commastring(name):
             return _set_metadata_and_copy(space, w_metadata,
                                 dtype_from_spec(space, w_dtype, alignment))
@@ -1454,17 +1454,17 @@
         }
         w_typeinfo = space.newdict()
         for k, v in typeinfo_partial.iteritems():
-            space.setitem(w_typeinfo, space.wrap(k), space.gettypefor(v))
+            space.setitem(w_typeinfo, space.newtext(k), space.gettypefor(v))
         for k, dtype in typeinfo_full.iteritems():
             itembits = dtype.elsize * 8
             if k in ('INTP', 'UINTP'):
                 char = getattr(NPY, k + 'LTR')
             else:
                 char = dtype.char
-            items_w = [space.wrap(char),
-                       space.wrap(dtype.num),
-                       space.wrap(itembits),
-                       space.wrap(dtype.itemtype.get_element_size())]
+            items_w = [space.newtext(char),
+                       space.newint(dtype.num),
+                       space.newint(itembits),
+                       space.newint(dtype.itemtype.get_element_size())]
             if dtype.is_int():
                 if dtype.is_bool():
                     w_maxobj = space.newint(1)
@@ -1478,7 +1478,7 @@
                     w_minobj = space.newint(0)
                 items_w = items_w + [w_maxobj, w_minobj]
             items_w = items_w + [dtype.w_box_type]
-            space.setitem(w_typeinfo, space.wrap(k), space.newtuple(items_w))
+            space.setitem(w_typeinfo, space.newtext(k), 
space.newtuple(items_w))
         self.w_typeinfo = w_typeinfo
 
 
diff --git a/pypy/module/micronumpy/flatiter.py 
b/pypy/module/micronumpy/flatiter.py
--- a/pypy/module/micronumpy/flatiter.py
+++ b/pypy/module/micronumpy/flatiter.py
@@ -40,14 +40,14 @@
         self.implementation = FakeArrayImplementation(self.base)
 
     def descr_base(self, space):
-        return space.wrap(self.base)
+        return self.base
 
     def descr_index(self, space):
-        return space.wrap(self.state.index)
+        return space.newint(self.state.index)
 
     def descr_coords(self, space):
         coords = self.iter.indices(self.state)
-        return space.newtuple([space.wrap(c) for c in coords])
+        return space.newtuple([space.newint(c) for c in coords])
 
     def descr_iter(self):
         return self
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -462,7 +462,7 @@
     signed = True
 
     def to_builtin_type(self, space, box):
-        return space.newint(self.for_computation(self.unbox(box)))
+        return space.wrap(self.for_computation(self.unbox(box)))
 
     def _base_coerce(self, space, w_item):
         if w_item is None:
@@ -740,7 +740,7 @@
     strlen = 32
 
     def to_builtin_type(self, space, box):
-        return space.wrap(self.for_computation(self.unbox(box)))
+        return space.newfloat(self.for_computation(self.unbox(box)))
 
     def _coerce(self, space, w_item):
         if w_item is None:
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -876,13 +876,13 @@
         w_op_dtypes = space.w_None
         for tf in need_to_cast:
             if tf:
-                w_casting = space.wrap('safe')
-                w_op_dtypes = space.newtuple([space.wrap(d) for d in dtypes])
-                
+                w_casting = space.newtext('safe')
+                w_op_dtypes = space.newtuple([d for d in dtypes])
+
         w_flags = space.w_None # NOT 'external_loop', we do coalescing by 
core_num_dims
-        w_ro = space.newtuple([space.wrap('readonly'), space.wrap('copy')])
-        w_rw = space.newtuple([space.wrap('readwrite'), 
space.wrap('updateifcopy')])
-        
+        w_ro = space.newtuple([space.newtext('readonly'), 
space.newtext('copy')])
+        w_rw = space.newtuple([space.newtext('readwrite'), 
space.newtext('updateifcopy')])
+
         w_op_flags = space.newtuple([w_ro] * len(inargs) + [w_rw] * 
len(outargs))
         w_op_axes = space.w_None
 
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
@@ -90,6 +90,8 @@
             self.builtin_types[typedef.name] = w_type
             setattr(self, 'w_' + typedef.name, w_type)
             self._interplevel_classes[w_type] = cls
+        self.w_bytes = self.w_str
+        self.w_text = self.w_str # this is w_unicode on Py3
         self.w_dict.flag_map_or_seq = 'M'
         self.builtin_types["NotImplemented"] = self.w_NotImplemented
         self.builtin_types["Ellipsis"] = self.w_Ellipsis
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to