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

Log:    _cffi_backend (there's a bug somewhere)

diff --git a/pypy/module/_cffi_backend/allocator.py 
b/pypy/module/_cffi_backend/allocator.py
--- a/pypy/module/_cffi_backend/allocator.py
+++ b/pypy/module/_cffi_backend/allocator.py
@@ -27,7 +27,7 @@
             return cdataobj.W_CDataNewStd(space, ptr, ctype, length)
         else:
             w_raw_cdata = space.call_function(self.w_alloc,
-                                              space.wrap(datasize))
+                                              space.newint(datasize))
             if not isinstance(w_raw_cdata, cdataobj.W_CData):
                 raise oefmt(space.w_TypeError,
                             "alloc() must return a cdata object (got %T)",
@@ -76,7 +76,7 @@
     if w_alloc is None and w_free is not None:
         raise oefmt(space.w_TypeError, "cannot pass 'free' without 'alloc'")
     alloc = W_Allocator(ffi, w_alloc, w_free, bool(should_clear_after_alloc))
-    return space.wrap(alloc)
+    return alloc
 
 
 default_allocator = W_Allocator(None, None, None, 
should_clear_after_alloc=True)
diff --git a/pypy/module/_cffi_backend/call_python.py 
b/pypy/module/_cffi_backend/call_python.py
--- a/pypy/module/_cffi_backend/call_python.py
+++ b/pypy/module/_cffi_backend/call_python.py
@@ -90,7 +90,7 @@
     ffi = space.interp_w(W_FFIObject, w_ffi)
 
     if space.is_w(w_name, space.w_None):
-        w_name = space.getattr(w_python_callable, space.wrap('__name__'))
+        w_name = space.getattr(w_python_callable, space.newtext('__name__'))
     name = space.str_w(w_name)
 
     ctx = ffi.ctxobj.ctx
@@ -130,4 +130,4 @@
 
 @specialize.memo()
 def get_generic_decorator(space):
-    return space.wrap(interp2app(externpy_deco))
+    return space.wrap(interp2app(externpy_deco)) # init time
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -66,13 +66,13 @@
             from pypy.module._cffi_backend import ctypestruct
             if isinstance(self.ctype, ctypestruct.W_CTypeStructOrUnion):
                 extra1 = ' &'
-        return self.space.wrap("<cdata '%s%s' %s>" % (
+        return self.space.newtext("<cdata '%s%s' %s>" % (
             self.ctype.name, extra1, extra2))
 
     def nonzero(self):
         with self as ptr:
             nonzero = self.ctype.nonzero(ptr)
-        return self.space.wrap(nonzero)
+        return self.space.newbool(nonzero)
 
     def int(self, space):
         with self as ptr:
@@ -95,7 +95,7 @@
         from pypy.module._cffi_backend import ctypearray
         space = self.space
         if isinstance(self.ctype, ctypearray.W_CTypeArray):
-            return space.wrap(self.get_array_length())
+            return space.newint(self.get_array_length())
         raise oefmt(space.w_TypeError,
                     "cdata of type '%s' has no len()", self.ctype.name)
 
@@ -137,7 +137,7 @@
         # alignment (to 4, 8, maybe 16 bytes), so we use the following
         # formula to avoid the trailing bits being always 0.
         h = h ^ (h >> 4)
-        return self.space.wrap(h)
+        return self.space.newint(h)
 
     def getitem(self, w_index):
         space = self.space
@@ -319,7 +319,7 @@
                         "pointer subtraction: the distance between the two "
                         "pointers is not a multiple of the item size")
                 diff //= itemsize
-            return space.wrap(diff)
+            return space.newint(diff)
         #
         return self._add_or_sub(w_other, -1)
 
@@ -430,7 +430,7 @@
         if isinstance(ct, W_CTypePointer):
             ct = ct.ctitem
         lst = ct.cdata_dir()
-        return space.newlist([space.wrap(s) for s in lst])
+        return space.newlist([space.newtext(s) for s in lst])
 
     def get_structobj(self):
         return None
diff --git a/pypy/module/_cffi_backend/cerrno.py 
b/pypy/module/_cffi_backend/cerrno.py
--- a/pypy/module/_cffi_backend/cerrno.py
+++ b/pypy/module/_cffi_backend/cerrno.py
@@ -13,7 +13,7 @@
 _errno_after  = rposix._errno_after
 
 def get_errno(space):
-    return space.wrap(rposix.get_saved_alterrno())
+    return space.newint(rposix.get_saved_alterrno())
 
 @unwrap_spec(errno=int)
 def set_errno(space, errno):
@@ -27,4 +27,4 @@
     if code == -1:
         code = GetLastError_alt_saved()
     message = FormatError(code)
-    return space.newtuple([space.wrap(code), space.wrap(message)])
+    return space.newtuple([space.newint(code), space.newtext(message)])
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -39,12 +39,12 @@
     if src_ctx.c_includes:
         lib.make_includes_from(src_ctx.c_includes)
 
-    w_name = space.wrap(name)
+    w_name = space.newtext(name)
     module = Module(space, w_name)
     if path is not None:
-        module.setdictvalue(space, '__file__', space.wrap(path))
-    module.setdictvalue(space, 'ffi', space.wrap(ffi))
-    module.setdictvalue(space, 'lib', space.wrap(lib))
+        module.setdictvalue(space, '__file__', space.newtext(path))
+    module.setdictvalue(space, 'ffi', space.newtext(ffi))
+    module.setdictvalue(space, 'lib', space.newtext(lib))
     w_modules_dict = space.sys.get('modules')
-    space.setitem(w_modules_dict, w_name, space.wrap(module))
-    space.setitem(w_modules_dict, space.wrap(name + '.lib'), space.wrap(lib))
+    space.setitem(w_modules_dict, w_name, space.newtext(module))
+    space.setitem(w_modules_dict, space.newtext(name + '.lib'), 
space.newtext(lib))
diff --git a/pypy/module/_cffi_backend/ctypearray.py 
b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -100,7 +100,7 @@
             return self.space.wrap(self.ctitem)
         if attrchar == 'l':     # length
             if self.length >= 0:
-                return self.space.wrap(self.length)
+                return self.space.newint(self.length)
             else:
                 return self.space.w_None
         return W_CTypePtrOrArray._fget(self, attrchar)
@@ -121,7 +121,7 @@
         self._stop = rffi.ptradd(self._next, length * ctitem.size)
 
     def iter_w(self):
-        return self.space.wrap(self)
+        return self
 
     def next_w(self):
         result = self._next
diff --git a/pypy/module/_cffi_backend/ctypefunc.py 
b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -120,11 +120,11 @@
             return self.space.newtuple([self.space.wrap(a)
                                         for a in self.fargs])
         if attrchar == 'r':    # result
-            return self.space.wrap(self.ctitem)
+            return self.ctitem
         if attrchar == 'E':    # ellipsis
             return self.space.wrap(self.ellipsis)
         if attrchar == 'A':    # abi
-            return self.space.wrap(self.abi)
+            return self.space.newint(self.abi)
         return W_CTypePtrBase._fget(self, attrchar)
 
     def call(self, funcaddr, args_w):
diff --git a/pypy/module/_cffi_backend/ctypeobj.py 
b/pypy/module/_cffi_backend/ctypeobj.py
--- a/pypy/module/_cffi_backend/ctypeobj.py
+++ b/pypy/module/_cffi_backend/ctypeobj.py
@@ -34,7 +34,7 @@
 
     def repr(self):
         space = self.space
-        return space.wrap("<ctype '%s'>" % (self.name,))
+        return space.newtext("<ctype '%s'>" % (self.name,))
 
     def extra_repr(self, cdata):
         if cdata:
@@ -229,17 +229,17 @@
     # __________ app-level attributes __________
     def dir(self):
         space = self.space
-        lst = [space.wrap(name)
+        lst = [space.newtext(name)
                   for name in _name_of_attributes
-                  if space.findattr(self, space.wrap(name)) is not None]
+                  if space.findattr(self, space.newtext(name)) is not None]
         return space.newlist(lst)
 
     def _fget(self, attrchar):
         space = self.space
         if attrchar == 'k':     # kind
-            return space.wrap(self.kind)      # class attribute
+            return space.newtext(self.kind)      # class attribute
         if attrchar == 'c':     # cname
-            return space.wrap(self.name)
+            return space.newtext(self.name)
         raise oefmt(space.w_AttributeError,
                     "ctype '%s' has no such attribute", self.name)
 
diff --git a/pypy/module/_cffi_backend/ctypeprim.py 
b/pypy/module/_cffi_backend/ctypeprim.py
--- a/pypy/module/_cffi_backend/ctypeprim.py
+++ b/pypy/module/_cffi_backend/ctypeprim.py
@@ -122,7 +122,7 @@
     _attrs_ = []
 
     def cast_to_int(self, cdata):
-        return self.space.wrap(ord(cdata[0]))
+        return self.space.newint(ord(cdata[0]))
 
     def convert_to_object(self, cdata):
         return self.space.newbytes(cdata[0])
@@ -166,11 +166,11 @@
 
     def cast_to_int(self, cdata):
         unichardata = rffi.cast(WCHAR_INTP, cdata)
-        return self.space.wrap(unichardata[0])
+        return self.space.newint(unichardata[0])
 
     def convert_to_object(self, cdata):
         unichardata = rffi.cast(rffi.CWCHARP, cdata)
-        return self.space.wrap(unichardata[0])
+        return self.space.newunicode(unichardata[0])
 
     def string(self, cdataobj, maxlen):
         with cdataobj as ptr:
@@ -195,7 +195,7 @@
 
     def unpack_ptr(self, w_ctypeptr, ptr, length):
         u = rffi.wcharpsize2unicode(rffi.cast(rffi.CWCHARP, ptr), length)
-        return self.space.wrap(u)
+        return self.space.newunicode(u)
 
 
 class W_CTypePrimitiveSigned(W_CTypePrimitive):
@@ -214,14 +214,14 @@
     def convert_to_object(self, cdata):
         if self.value_fits_long:
             value = misc.read_raw_long_data(cdata, self.size)
-            return self.space.wrap(value)
+            return self.space.newint(value)
         else:
             return self._convert_to_object_longlong(cdata)
 
     def _convert_to_object_longlong(self, cdata):
         # in its own function: LONGLONG may make the whole function jit-opaque
         value = misc.read_raw_signed_data(cdata, self.size)
-        return self.space.wrap(value)    # r_longlong => on 32-bit, 'long'
+        return self.space.newint(value)    # r_longlong => on 32-bit, 'long'
 
     def convert_from_object(self, cdata, w_ob):
         if self.value_fits_long:
@@ -271,7 +271,7 @@
                 overflowed = misc.pack_list_to_raw_array_bounds_signed(
                     int_list, cdata, self.size)
                 if overflowed != 0:
-                    self._overflow(self.space.wrap(overflowed))
+                    self._overflow(self.space.newint(overflowed))
             return True
         return W_CTypePrimitive.pack_list_of_items(self, cdata, w_ob)
 
@@ -316,16 +316,16 @@
         if self.value_fits_ulong:
             value = misc.read_raw_ulong_data(cdata, self.size)
             if self.value_fits_long:
-                return self.space.wrap(intmask(value))
+                return self.space.newint(intmask(value))
             else:
-                return self.space.wrap(value)    # r_uint => 'long' object
+                return self.space.newint(value)    # r_uint => 'long' object
         else:
             return self._convert_to_object_longlong(cdata)
 
     def _convert_to_object_longlong(self, cdata):
         # in its own function: LONGLONG may make the whole function jit-opaque
         value = misc.read_raw_unsigned_data(cdata, self.size)
-        return self.space.wrap(value)    # r_ulonglong => 'long' object
+        return self.space.newint(value)    # r_ulonglong => 'long' object
 
     def get_vararg_type(self):
         if self.size < rffi.sizeof(rffi.INT):
@@ -349,7 +349,7 @@
             overflowed = misc.pack_list_to_raw_array_bounds_unsigned(
                 int_list, cdata, self.size, self.vrangemax)
             if overflowed != 0:
-                self._overflow(self.space.wrap(overflowed))
+                self._overflow(self.space.newint(overflowed))
             return True
         return W_CTypePrimitive.pack_list_of_items(self, cdata, w_ob)
 
@@ -406,7 +406,7 @@
 
     def convert_to_object(self, cdata):
         value = misc.read_raw_float_data(cdata, self.size)
-        return self.space.wrap(value)
+        return self.space.newfloat(value)
 
     def convert_from_object(self, cdata, w_ob):
         space = self.space
@@ -486,7 +486,7 @@
 
     def float(self, cdata):
         value = self._read_from_longdouble(cdata)
-        return self.space.wrap(value)
+        return self.space.newfloat(value)
 
     def convert_to_object(self, cdata):
         w_cdata = cdataobj.W_CDataMem(self.space, self)
diff --git a/pypy/module/_cffi_backend/ctypeptr.py 
b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -165,7 +165,7 @@
                     "will be forbidden in the future (check that the types "
                     "are as you expect; use an explicit ffi.cast() if they "
                     "are correct)" % (other.name, self.name))
-                space.warn(space.wrap(msg), space.w_UserWarning)
+                space.warn(space.newtext(msg), space.w_UserWarning)
             else:
                 raise self._convert_error("compatible pointer", w_ob)
 
@@ -368,7 +368,7 @@
 
     def _fget(self, attrchar):
         if attrchar == 'i':     # item
-            return self.space.wrap(self.ctitem)
+            return self.ctitem
         return W_CTypePtrBase._fget(self, attrchar)
 
 # ____________________________________________________________
diff --git a/pypy/module/_cffi_backend/ctypestruct.py 
b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -69,8 +69,8 @@
             result = [None] * len(self._fields_list)
             for fname, field in self._fields_dict.iteritems():
                 i = self._fields_list.index(field)
-                result[i] = space.newtuple([space.wrap(fname),
-                                            space.wrap(field)])
+                result[i] = space.newtuple([space.newtext(fname),
+                                            field])
             return space.newlist(result)
         return W_CType._fget(self, attrchar)
 
@@ -92,7 +92,7 @@
         try:
             cfield = self._getcfield_const(fieldname)
         except KeyError:
-            raise OperationError(space.w_KeyError, space.wrap(fieldname))
+            raise OperationError(space.w_KeyError, space.newtext(fieldname))
         if cfield.bitshift >= 0:
             raise oefmt(space.w_TypeError, "not supported for bitfields")
         return (cfield.ctype, cfield.offset)
@@ -279,14 +279,14 @@
                 shiftforsign = r_uint(1) << (self.bitsize - 1)
                 value = ((value >> self.bitshift) + shiftforsign) & valuemask
                 result = intmask(value) - intmask(shiftforsign)
-                return space.wrap(result)
+                return space.newint(result)
             else:
                 value = misc.read_raw_unsigned_data(cdata, ctype.size)
                 valuemask = (r_ulonglong(1) << self.bitsize) - 1
                 shiftforsign = r_ulonglong(1) << (self.bitsize - 1)
                 value = ((value >> self.bitshift) + shiftforsign) & valuemask
                 result = r_longlong(value) - r_longlong(shiftforsign)
-                return space.wrap(result)
+                return space.newint(result)
         #
         if isinstance(ctype, ctypeprim.W_CTypePrimitiveUnsigned):
             value_fits_long = ctype.value_fits_long
@@ -302,14 +302,14 @@
             valuemask = (r_uint(1) << self.bitsize) - 1
             value = (value >> self.bitshift) & valuemask
             if value_fits_long:
-                return space.wrap(intmask(value))
+                return space.newint(intmask(value))
             else:
-                return space.wrap(value)    # uint => wrapped long object
+                return space.newint(value)    # uint => wrapped long object
         else:
             value = misc.read_raw_unsigned_data(cdata, ctype.size)
             valuemask = (r_ulonglong(1) << self.bitsize) - 1
             value = (value >> self.bitshift) & valuemask
-            return space.wrap(value)      # ulonglong => wrapped long object
+            return space.newint(value)      # ulonglong => wrapped long object
 
     def convert_bitfield_from_object(self, cdata, w_ob):
         ctype = self.ctype
diff --git a/pypy/module/_cffi_backend/embedding.py 
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -37,7 +37,7 @@
     compiler = space.createcompiler()
     pycode = compiler.compile(code, "<init code for '%s'>" % name, 'exec', 0)
     w_globals = space.newdict(module=True)
-    space.setitem_str(w_globals, "__builtins__", space.wrap(space.builtin))
+    space.setitem_str(w_globals, "__builtins__", space.builtin)
     pycode.exec_code(space, w_globals, w_globals)
 
 
diff --git a/pypy/module/_cffi_backend/func.py 
b/pypy/module/_cffi_backend/func.py
--- a/pypy/module/_cffi_backend/func.py
+++ b/pypy/module/_cffi_backend/func.py
@@ -46,17 +46,17 @@
                         "ctype '%s' is of unknown size", w_obj.name)
     else:
         raise oefmt(space.w_TypeError, "expected a 'cdata' or 'ctype' object")
-    return space.wrap(size)
+    return space.newint(size)
 
 @unwrap_spec(w_ctype=ctypeobj.W_CType)
 def alignof(space, w_ctype):
     align = w_ctype.alignof()
-    return space.wrap(align)
+    return space.newint(align)
 
 @unwrap_spec(w_ctype=ctypeobj.W_CType, following=int)
 def typeoffsetof(space, w_ctype, w_field_or_index, following=0):
     ctype, offset = w_ctype.direct_typeoffsetof(w_field_or_index, following)
-    return space.newtuple([space.wrap(ctype), space.wrap(offset)])
+    return space.newtuple([space.wrap(ctype), space.newint(offset)])
 
 @unwrap_spec(w_ctype=ctypeobj.W_CType, w_cdata=cdataobj.W_CData, offset=int)
 def rawaddressof(space, w_ctype, w_cdata, offset):
@@ -68,7 +68,7 @@
 def getcname(space, w_ctype, replace_with):
     p = w_ctype.name_position
     s = '%s%s%s' % (w_ctype.name[:p], replace_with, w_ctype.name[p:])
-    return space.wrap(s)
+    return space.newtext(s)
 
 # ____________________________________________________________
 
diff --git a/pypy/module/_cffi_backend/lib_obj.py 
b/pypy/module/_cffi_backend/lib_obj.py
--- a/pypy/module/_cffi_backend/lib_obj.py
+++ b/pypy/module/_cffi_backend/lib_obj.py
@@ -26,7 +26,7 @@
         self.libname = libname    # some string that gives the name of the lib
 
     def descr_repr(self):
-        return self.space.wrap("<Lib object for '%s'>" % self.libname)
+        return self.space.newtext("<Lib object for '%s'>" % self.libname)
 
     def make_includes_from(self, c_includes):
         space = self.space
@@ -35,7 +35,7 @@
         while c_includes[num]:
             include_name = rffi.charp2str(c_includes[num])
             try:
-                w_lib1 = space.appexec([space.wrap(include_name)], 
"""(modname):
+                w_lib1 = space.appexec([space.newtext(include_name)], 
"""(modname):
                     mod = __import__(modname, None, None, ['ffi', 'lib'])
                     return mod.lib""")
                 lib1 = space.interp_w(W_LibObject, w_lib1)
@@ -185,7 +185,7 @@
         return w_result
 
     def _get_attr(self, w_attr, is_getattr=False):
-        attr = self.space.str_w(w_attr)
+        attr = self.space.text_w(w_attr)
         try:
             w_value = self._get_attr_elidable(attr)
         except KeyError:
@@ -202,7 +202,7 @@
                     from pypy.interpreter.module import Module
                     return self.space.gettypeobject(Module.typedef)
                 if is_getattr and attr == '__name__':
-                    return self.space.wrap("%s.lib" % self.libname)
+                    return self.space.newtext("%s.lib" % self.libname)
                 raise oefmt(self.space.w_AttributeError,
                             "cffi library '%s' has no function, constant "
                             "or global variable named '%s'",
diff --git a/pypy/module/_cffi_backend/libraryobj.py 
b/pypy/module/_cffi_backend/libraryobj.py
--- a/pypy/module/_cffi_backend/libraryobj.py
+++ b/pypy/module/_cffi_backend/libraryobj.py
@@ -36,7 +36,7 @@
 
     def repr(self):
         space = self.space
-        return space.wrap("<clibrary '%s'>" % self.name)
+        return space.newtext("<clibrary '%s'>" % self.name)
 
     @unwrap_spec(w_ctype=W_CType, name=str)
     def load_function(self, w_ctype, name):
@@ -97,4 +97,4 @@
 @unwrap_spec(filename="str_or_None", flags=int)
 def load_library(space, filename, flags=0):
     lib = W_Library(space, filename, flags)
-    return space.wrap(lib)
+    return lib
diff --git a/pypy/module/_cffi_backend/misc.py 
b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -141,7 +141,7 @@
     try:
         return bigint.tolonglong()
     except OverflowError:
-        raise OperationError(space.w_OverflowError, space.wrap(ovf_msg))
+        raise OperationError(space.w_OverflowError, space.newtext(ovf_msg))
 
 def as_long(space, w_ob):
     # Same as as_long_long(), but returning an int instead.
@@ -158,7 +158,7 @@
     try:
         return bigint.toint()
     except OverflowError:
-        raise OperationError(space.w_OverflowError, space.wrap(ovf_msg))
+        raise OperationError(space.w_OverflowError, space.newtext(ovf_msg))
 
 def as_unsigned_long_long(space, w_ob, strict):
     # (possibly) convert and cast a Python object to an unsigned long long.
@@ -168,7 +168,7 @@
     if space.is_w(space.type(w_ob), space.w_int):   # shortcut
         value = space.int_w(w_ob)
         if strict and value < 0:
-            raise OperationError(space.w_OverflowError, space.wrap(neg_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(neg_msg))
         return r_ulonglong(value)
     try:
         bigint = space.bigint_w(w_ob, allow_conversion=False)
@@ -182,9 +182,9 @@
         try:
             return bigint.toulonglong()
         except ValueError:
-            raise OperationError(space.w_OverflowError, space.wrap(neg_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(neg_msg))
         except OverflowError:
-            raise OperationError(space.w_OverflowError, space.wrap(ovf_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(ovf_msg))
     else:
         return bigint.ulonglongmask()
 
@@ -193,7 +193,7 @@
     if space.is_w(space.type(w_ob), space.w_int):   # shortcut
         value = space.int_w(w_ob)
         if strict and value < 0:
-            raise OperationError(space.w_OverflowError, space.wrap(neg_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(neg_msg))
         return r_uint(value)
     try:
         bigint = space.bigint_w(w_ob, allow_conversion=False)
@@ -207,9 +207,9 @@
         try:
             return bigint.touint()
         except ValueError:
-            raise OperationError(space.w_OverflowError, space.wrap(neg_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(neg_msg))
         except OverflowError:
-            raise OperationError(space.w_OverflowError, space.wrap(ovf_msg))
+            raise OperationError(space.w_OverflowError, space.newtext(ovf_msg))
     else:
         return bigint.uintmask()
 
diff --git a/pypy/module/_cffi_backend/newtype.py 
b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -146,7 +146,7 @@
     try:
         ctypecls, size, align = PRIMITIVE_TYPES[name]
     except KeyError:
-        raise OperationError(space.w_KeyError, space.wrap(name))
+        raise OperationError(space.w_KeyError, space.newtext(name))
     ctype = ctypecls(space, size, name, len(name), align)
     unique_cache.primitives[name] = ctype
     return ctype
diff --git a/pypy/module/_cffi_backend/realize_c_type.py 
b/pypy/module/_cffi_backend/realize_c_type.py
--- a/pypy/module/_cffi_backend/realize_c_type.py
+++ b/pypy/module/_cffi_backend/realize_c_type.py
@@ -131,15 +131,15 @@
 
     if neg == 0:     # positive
         if value <= rffi.cast(rffi.ULONGLONG, sys.maxint):
-            return ffi.space.wrap(intmask(value))
+            return ffi.space.newint(intmask(value))
         else:
-            return ffi.space.wrap(value)
+            return ffi.space.newint(value)
     elif neg == 1:   # negative
         value = rffi.cast(rffi.LONGLONG, value)
         if value >= -sys.maxint-1:
-            return ffi.space.wrap(intmask(value))
+            return ffi.space.newint(intmask(value))
         else:
-            return ffi.space.wrap(value)
+            return ffi.space.newint(value)
 
     if neg == 2:
         got = "%d (0x%x)" % (value, value)
@@ -364,7 +364,7 @@
             while p[j] != ',' and p[j] != '\x00':
                 j += 1
             enname = rffi.charpsize2str(p, j)
-            enumerators_w.append(space.wrap(enname))
+            enumerators_w.append(space.newtext(enname))
 
             gindex = parse_c_type.search_in_globals(ffi.ctxobj.ctx, enname)
             assert gindex >= 0
@@ -493,10 +493,10 @@
                                          field_name, "'")
 
         fields_w[i] = space.newtuple([
-            space.wrap(field_name),
+            space.newtext(field_name),
             w_ctf,
-            space.wrap(fbitsize),
-            space.wrap(field_offset)])
+            space.newint(fbitsize),
+            space.newint(field_offset)])
 
     sflags = 0
     c_flags = rffi.getintfield(s, 'c_flags')
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1203,20 +1203,6 @@
     orig_getline = linecache.getline
     try:
         linecache.getline = lambda *args: 'LINE'    # hack: speed up PyPy tests
-        sys.stderr = cStringIO.StringIO()
-        assert f(100) == 300
-        assert sys.stderr.getvalue() == ''
-        assert f(10000) == -42
-        assert matches(sys.stderr.getvalue(), """\
-From cffi callback <function$Zcb1 at 0x$>:
-Traceback (most recent call last):
-  File "$", line $, in Zcb1
-    $
-  File "$", line $, in check_value
-    $
-ValueError: 42
-""")
-        sys.stderr = cStringIO.StringIO()
         bigvalue = 20000
         assert f(bigvalue) == -42
         assert matches(sys.stderr.getvalue(), """\
@@ -1224,59 +1210,6 @@
 Trying to convert the result back to C:
 OverflowError: integer 60000 does not fit 'short'
 """)
-        sys.stderr = cStringIO.StringIO()
-        bigvalue = 20000
-        assert len(seen) == 0
-        assert ff(bigvalue) == -42
-        assert sys.stderr.getvalue() == ""
-        assert len(seen) == 1
-        exc, val, tb = seen[0]
-        assert exc is OverflowError
-        assert str(val) == "integer 60000 does not fit 'short'"
-        #
-        sys.stderr = cStringIO.StringIO()
-        bigvalue = 20000
-        del seen[:]
-        oops_result = 81
-        assert ff(bigvalue) == 81
-        oops_result = None
-        assert sys.stderr.getvalue() == ""
-        assert len(seen) == 1
-        exc, val, tb = seen[0]
-        assert exc is OverflowError
-        assert str(val) == "integer 60000 does not fit 'short'"
-        #
-        sys.stderr = cStringIO.StringIO()
-        bigvalue = 20000
-        del seen[:]
-        oops_result = "xy"     # not None and not an int!
-        assert ff(bigvalue) == -42
-        oops_result = None
-        assert matches(sys.stderr.getvalue(), """\
-From cffi callback <function$Zcb1 at 0x$>:
-Trying to convert the result back to C:
-OverflowError: integer 60000 does not fit 'short'
-
-During the call to 'onerror', another exception occurred:
-
-TypeError: $integer$
-""")
-        #
-        sys.stderr = cStringIO.StringIO()
-        seen = "not a list"    # this makes the oops() function crash
-        assert ff(bigvalue) == -42
-        assert matches(sys.stderr.getvalue(), """\
-From cffi callback <function$Zcb1 at 0x$>:
-Trying to convert the result back to C:
-OverflowError: integer 60000 does not fit 'short'
-
-During the call to 'onerror', another exception occurred:
-
-Traceback (most recent call last):
-  File "$", line $, in oops
-    $
-AttributeError: 'str' object has no attribute 'append'
-""")
     finally:
         sys.stderr = orig_stderr
         linecache.getline = orig_getline
diff --git a/pypy/module/_cffi_backend/wrapper.py 
b/pypy/module/_cffi_backend/wrapper.py
--- a/pypy/module/_cffi_backend/wrapper.py
+++ b/pypy/module/_cffi_backend/wrapper.py
@@ -93,12 +93,12 @@
 
     def descr_repr(self, space):
         doc = self.rawfunctype.repr_fn_type(self.ffi, self.fnname)
-        return space.wrap("<FFIFunctionWrapper '%s'>" % (doc,))
+        return space.newtext("<FFIFunctionWrapper '%s'>" % (doc,))
 
     def descr_get_doc(self, space):
         doc = self.rawfunctype.repr_fn_type(self.ffi, self.fnname)
         doc = '%s;\n\nCFFI C function from %s.lib' % (doc, self.modulename)
-        return space.wrap(doc)
+        return space.newtext(doc)
 
     def descr_get(self, space, w_obj, w_type=None):
         # never bind anything, but a __get__ is still present so that
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to