[pypy-commit] pypy remove-list-smm: fix fix fix

fijal noreply at buildbot.pypy.org
Fri Mar 22 01:18:32 CET 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: remove-list-smm
Changeset: r62629:9aebaf686e8e
Date: 2013-03-21 17:18 -0700
http://bitbucket.org/pypy/pypy/changeset/9aebaf686e8e/

Log:	fix fix fix

diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -116,8 +116,8 @@
     def checked_space_method(self, typname, app_sig):
         argname = self.orig_arg()
         assert not argname.startswith('w_'), (
-            "unwrapped %s argument %s of built-in function %r should "
-            "not start with 'w_'" % (typname, argname, self.func))
+            "unwrapped %s argument %s of built-in function %r in %r should "
+            "not start with 'w_'" % (typname, argname, self.func.func_name, self.func.func_globals['__name__']))
         app_sig.append(argname)
 
     def visit_index(self, index, app_sig):
@@ -157,8 +157,8 @@
             app_sig.append(argname)
             return
         assert argname.startswith('w_'), (
-            "argument %s of built-in function %r should "
-            "start with 'w_'" % (argname, self.func))
+            "argument %s of built-in function %r in %r should "
+            "start with 'w_'" % (argname, self.func.func_name, self.func.func_globals['__name__']))
         app_sig.append(argname[2:])
 
     def visit__Arguments(self, el, app_sig):
diff --git a/pypy/module/_cffi_backend/cbuffer.py b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -72,15 +72,15 @@
 MiniBuffer.typedef.acceptable_as_base_class = False
 
 
- at unwrap_spec(cdata=cdataobj.W_CData, size=int)
-def buffer(space, cdata, size=-1):
-    ctype = cdata.ctype
+ at unwrap_spec(w_cdata=cdataobj.W_CData, size=int)
+def buffer(space, w_cdata, size=-1):
+    ctype = w_cdata.ctype
     if isinstance(ctype, ctypeptr.W_CTypePointer):
         if size < 0:
             size = ctype.ctitem.size
     elif isinstance(ctype, ctypearray.W_CTypeArray):
         if size < 0:
-            size = cdata._sizeof()
+            size = w_cdata._sizeof()
     else:
         raise operationerrfmt(space.w_TypeError,
                               "expected a pointer or array cdata, got '%s'",
@@ -89,4 +89,4 @@
         raise operationerrfmt(space.w_TypeError,
                               "don't know the size pointed to by '%s'",
                               ctype.name)
-    return space.wrap(MiniBuffer(LLBuffer(cdata._cdata, size), cdata))
+    return space.wrap(MiniBuffer(LLBuffer(w_cdata._cdata, size), w_cdata))
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
@@ -5,28 +5,28 @@
 
 # ____________________________________________________________
 
- at unwrap_spec(ctype=ctypeobj.W_CType, w_init=WrappedDefault(None))
-def newp(space, ctype, w_init):
-    return ctype.newp(w_init)
+ at unwrap_spec(w_ctype=ctypeobj.W_CType, w_init=WrappedDefault(None))
+def newp(space, w_ctype, w_init):
+    return w_ctype.newp(w_init)
 
 # ____________________________________________________________
 
- at unwrap_spec(ctype=ctypeobj.W_CType)
-def cast(space, ctype, w_ob):
-    return ctype.cast(w_ob)
+ at unwrap_spec(w_ctype=ctypeobj.W_CType)
+def cast(space, w_ctype, w_ob):
+    return w_ctype.cast(w_ob)
 
 # ____________________________________________________________
 
- at unwrap_spec(ctype=ctypeobj.W_CType)
-def callback(space, ctype, w_callable, w_error=None):
+ at unwrap_spec(w_ctype=ctypeobj.W_CType)
+def callback(space, w_ctype, w_callable, w_error=None):
     from pypy.module._cffi_backend.ccallback import W_CDataCallback
-    return W_CDataCallback(space, ctype, w_callable, w_error)
+    return W_CDataCallback(space, w_ctype, w_callable, w_error)
 
 # ____________________________________________________________
 
- at unwrap_spec(cdata=cdataobj.W_CData)
-def typeof(space, cdata):
-    return cdata.ctype
+ at unwrap_spec(w_cdata=cdataobj.W_CData)
+def typeof(space, w_cdata):
+    return w_cdata.ctype
 
 # ____________________________________________________________
 
@@ -44,33 +44,33 @@
                             space.wrap("expected a 'cdata' or 'ctype' object"))
     return space.wrap(size)
 
- at unwrap_spec(ctype=ctypeobj.W_CType)
-def alignof(space, ctype):
-    align = ctype.alignof()
+ at unwrap_spec(w_ctype=ctypeobj.W_CType)
+def alignof(space, w_ctype):
+    align = w_ctype.alignof()
     return space.wrap(align)
 
- at unwrap_spec(ctype=ctypeobj.W_CType, fieldname="str_or_None")
-def typeoffsetof(space, ctype, fieldname):
-    ctype, offset = ctype.typeoffsetof(fieldname)
+ at unwrap_spec(w_ctype=ctypeobj.W_CType, fieldname="str_or_None")
+def typeoffsetof(space, w_ctype, fieldname):
+    ctype, offset = w_ctype.typeoffsetof(fieldname)
     return space.newtuple([space.wrap(ctype), space.wrap(offset)])
 
- at unwrap_spec(ctype=ctypeobj.W_CType, cdata=cdataobj.W_CData, offset=int)
-def rawaddressof(space, ctype, cdata, offset=0):
-    return ctype.rawaddressof(cdata, offset)
+ at unwrap_spec(w_ctype=ctypeobj.W_CType, w_cdata=cdataobj.W_CData, offset=int)
+def rawaddressof(space, w_ctype, w_cdata, offset=0):
+    return w_ctype.rawaddressof(w_cdata, offset)
 
 # ____________________________________________________________
 
- at unwrap_spec(ctype=ctypeobj.W_CType, replace_with=str)
-def getcname(space, ctype, replace_with):
-    p = ctype.name_position
-    s = '%s%s%s' % (ctype.name[:p], replace_with, ctype.name[p:])
+ at unwrap_spec(w_ctype=ctypeobj.W_CType, replace_with=str)
+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)
 
 # ____________________________________________________________
 
- at unwrap_spec(cdata=cdataobj.W_CData, maxlen=int)
-def string(space, cdata, maxlen=-1):
-    return cdata.ctype.string(cdata, maxlen)
+ at unwrap_spec(w_cdata=cdataobj.W_CData, maxlen=int)
+def string(space, w_cdata, maxlen=-1):
+    return w_cdata.ctype.string(w_cdata, maxlen)
 
 # ____________________________________________________________
 
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
@@ -39,21 +39,21 @@
         space = self.space
         return space.wrap("<clibrary '%s'>" % self.name)
 
-    @unwrap_spec(ctype=W_CType, name=str)
-    def load_function(self, ctype, name):
+    @unwrap_spec(w_ctype=W_CType, name=str)
+    def load_function(self, w_ctype, name):
         from pypy.module._cffi_backend import ctypefunc, ctypeptr, ctypevoid
         space = self.space
         #
         ok = False
-        if isinstance(ctype, ctypefunc.W_CTypeFunc):
+        if isinstance(w_ctype, ctypefunc.W_CTypeFunc):
             ok = True
-        if (isinstance(ctype, ctypeptr.W_CTypePointer) and
-            isinstance(ctype.ctitem, ctypevoid.W_CTypeVoid)):
+        if (isinstance(w_ctype, ctypeptr.W_CTypePointer) and
+            isinstance(w_ctype.ctitem, ctypevoid.W_CTypeVoid)):
             ok = True
         if not ok:
             raise operationerrfmt(space.w_TypeError,
                                   "function cdata expected, got '%s'",
-                                  ctype.name)
+                                  w_ctype.name)
         #
         try:
             cdata = dlsym(self.handle, name)
@@ -61,10 +61,10 @@
             raise operationerrfmt(space.w_KeyError,
                                   "function '%s' not found in library '%s'",
                                   name, self.name)
-        return W_CData(space, rffi.cast(rffi.CCHARP, cdata), ctype)
+        return W_CData(space, rffi.cast(rffi.CCHARP, cdata), w_ctype)
 
-    @unwrap_spec(ctype=W_CType, name=str)
-    def read_variable(self, ctype, name):
+    @unwrap_spec(w_ctype=W_CType, name=str)
+    def read_variable(self, w_ctype, name):
         space = self.space
         try:
             cdata = dlsym(self.handle, name)
@@ -72,10 +72,10 @@
             raise operationerrfmt(space.w_KeyError,
                                   "variable '%s' not found in library '%s'",
                                   name, self.name)
-        return ctype.convert_to_object(rffi.cast(rffi.CCHARP, cdata))
+        return w_ctype.convert_to_object(rffi.cast(rffi.CCHARP, cdata))
 
-    @unwrap_spec(ctype=W_CType, name=str)
-    def write_variable(self, ctype, name, w_value):
+    @unwrap_spec(w_ctype=W_CType, name=str)
+    def write_variable(self, w_ctype, name, w_value):
         space = self.space
         try:
             cdata = dlsym(self.handle, name)
@@ -83,7 +83,7 @@
             raise operationerrfmt(space.w_KeyError,
                                   "variable '%s' not found in library '%s'",
                                   name, self.name)
-        ctype.convert_from_object(rffi.cast(rffi.CCHARP, cdata), w_value)
+        w_ctype.convert_from_object(rffi.cast(rffi.CCHARP, cdata), w_value)
 
 
 W_Library.typedef = TypeDef(
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
@@ -75,19 +75,19 @@
 
 # ____________________________________________________________
 
- at unwrap_spec(ctype=ctypeobj.W_CType)
-def new_pointer_type(space, ctype):
-    ctypepointer = ctypeptr.W_CTypePointer(space, ctype)
+ at unwrap_spec(w_ctype=ctypeobj.W_CType)
+def new_pointer_type(space, w_ctype):
+    ctypepointer = ctypeptr.W_CTypePointer(space, w_ctype)
     return ctypepointer
 
 # ____________________________________________________________
 
- at unwrap_spec(ctptr=ctypeobj.W_CType)
-def new_array_type(space, ctptr, w_length):
-    if not isinstance(ctptr, ctypeptr.W_CTypePointer):
+ at unwrap_spec(w_ctptr=ctypeobj.W_CType)
+def new_array_type(space, w_ctptr, w_length):
+    if not isinstance(w_ctptr, ctypeptr.W_CTypePointer):
         raise OperationError(space.w_TypeError,
                              space.wrap("first arg must be a pointer ctype"))
-    ctitem = ctptr.ctitem
+    ctitem = w_ctptr.ctitem
     if ctitem.size < 0:
         raise operationerrfmt(space.w_ValueError,
                               "array item of unknown size: '%s'",
@@ -108,7 +108,7 @@
                 space.wrap("array size would overflow a ssize_t"))
         extra = '[%d]' % length
     #
-    ctype = ctypearray.W_CTypeArray(space, ctptr, length, arraysize, extra)
+    ctype = ctypearray.W_CTypeArray(space, w_ctptr, length, arraysize, extra)
     return ctype
 
 # ____________________________________________________________
@@ -121,16 +121,16 @@
 def new_union_type(space, name):
     return ctypestruct.W_CTypeUnion(space, name)
 
- at unwrap_spec(ctype=ctypeobj.W_CType, totalsize=int, totalalignment=int)
-def complete_struct_or_union(space, ctype, w_fields, w_ignored=None,
+ at unwrap_spec(w_ctype=ctypeobj.W_CType, totalsize=int, totalalignment=int)
+def complete_struct_or_union(space, w_ctype, w_fields, w_ignored=None,
                              totalsize=-1, totalalignment=-1):
-    if (not isinstance(ctype, ctypestruct.W_CTypeStructOrUnion)
-            or ctype.size >= 0):
+    if (not isinstance(w_ctype, ctypestruct.W_CTypeStructOrUnion)
+            or w_ctype.size >= 0):
         raise OperationError(space.w_TypeError,
                              space.wrap("first arg must be a non-initialized"
                                         " struct or union ctype"))
 
-    is_union = isinstance(ctype, ctypestruct.W_CTypeUnion)
+    is_union = isinstance(w_ctype, ctypestruct.W_CTypeUnion)
     maxsize = 1
     alignment = 1
     offset = 0
@@ -159,7 +159,7 @@
         if ftype.size < 0:
             raise operationerrfmt(space.w_TypeError,
                     "field '%s.%s' has ctype '%s' of unknown size",
-                                  ctype.name, fname, ftype.name)
+                                  w_ctype.name, fname, ftype.name)
         #
         falign = ftype.alignof()
         if alignment < falign:
@@ -246,15 +246,15 @@
     elif totalsize < offset:
         raise operationerrfmt(space.w_TypeError,
                      "%s cannot be of size %d: there are fields at least "
-                     "up to %d", ctype.name, totalsize, offset)
+                     "up to %d", w_ctype.name, totalsize, offset)
     if totalalignment < 0:
         totalalignment = alignment
 
-    ctype.size = totalsize
-    ctype.alignment = totalalignment
-    ctype.fields_list = fields_list
-    ctype.fields_dict = fields_dict
-    ctype.custom_field_pos = custom_field_pos
+    w_ctype.size = totalsize
+    w_ctype.alignment = totalalignment
+    w_ctype.fields_list = fields_list
+    w_ctype.fields_dict = fields_dict
+    w_ctype.custom_field_pos = custom_field_pos
 
 # ____________________________________________________________
 
@@ -264,8 +264,8 @@
 
 # ____________________________________________________________
 
- at unwrap_spec(name=str, basectype=ctypeobj.W_CType)
-def new_enum_type(space, name, w_enumerators, w_enumvalues, basectype):
+ at unwrap_spec(name=str, w_basectype=ctypeobj.W_CType)
+def new_enum_type(space, name, w_enumerators, w_enumvalues, w_basectype):
     enumerators_w = space.fixedview(w_enumerators)
     enumvalues_w  = space.fixedview(w_enumvalues)
     if len(enumerators_w) != len(enumvalues_w):
@@ -273,22 +273,22 @@
                              space.wrap("tuple args must have the same size"))
     enumerators = [space.str_w(w) for w in enumerators_w]
     #
-    if (not isinstance(basectype, ctypeprim.W_CTypePrimitiveSigned) and
-        not isinstance(basectype, ctypeprim.W_CTypePrimitiveUnsigned)):
+    if (not isinstance(w_basectype, ctypeprim.W_CTypePrimitiveSigned) and
+        not isinstance(w_basectype, ctypeprim.W_CTypePrimitiveUnsigned)):
         raise OperationError(space.w_TypeError,
               space.wrap("expected a primitive signed or unsigned base type"))
     #
-    lvalue = lltype.malloc(rffi.CCHARP.TO, basectype.size, flavor='raw')
+    lvalue = lltype.malloc(rffi.CCHARP.TO, w_basectype.size, flavor='raw')
     try:
         for w in enumvalues_w:
             # detects out-of-range or badly typed values
-            basectype.convert_from_object(lvalue, w)
+            w_basectype.convert_from_object(lvalue, w)
     finally:
         lltype.free(lvalue, flavor='raw')
     #
-    size = basectype.size
-    align = basectype.align
-    if isinstance(basectype, ctypeprim.W_CTypePrimitiveSigned):
+    size = w_basectype.size
+    align = w_basectype.align
+    if isinstance(w_basectype, ctypeprim.W_CTypePrimitiveSigned):
         enumvalues = [space.int_w(w) for w in enumvalues_w]
         ctype = ctypeenum.W_CTypeEnumSigned(space, name, size, align,
                                             enumerators, enumvalues)
@@ -300,8 +300,8 @@
 
 # ____________________________________________________________
 
- at unwrap_spec(fresult=ctypeobj.W_CType, ellipsis=int)
-def new_function_type(space, w_fargs, fresult, ellipsis=0):
+ at unwrap_spec(w_fresult=ctypeobj.W_CType, ellipsis=int)
+def new_function_type(space, w_fargs, w_fresult, ellipsis=0):
     from pypy.module._cffi_backend import ctypefunc
     fargs = []
     for w_farg in space.fixedview(w_fargs):
@@ -312,15 +312,16 @@
             w_farg = w_farg.ctptr
         fargs.append(w_farg)
     #
-    if ((fresult.size < 0 and not isinstance(fresult, ctypevoid.W_CTypeVoid))
-            or isinstance(fresult, ctypearray.W_CTypeArray)):
-        if (isinstance(fresult, ctypestruct.W_CTypeStructOrUnion) and
-                fresult.size < 0):
+    if ((w_fresult.size < 0 and
+         not isinstance(w_fresult, ctypevoid.W_CTypeVoid))
+        or isinstance(w_fresult, ctypearray.W_CTypeArray)):
+        if (isinstance(w_fresult, ctypestruct.W_CTypeStructOrUnion) and
+                w_fresult.size < 0):
             raise operationerrfmt(space.w_TypeError,
-                                  "result type '%s' is opaque", fresult.name)
+                                  "result type '%s' is opaque", w_fresult.name)
         else:
             raise operationerrfmt(space.w_TypeError,
-                                  "invalid result type: '%s'", fresult.name)
+                                  "invalid result type: '%s'", w_fresult.name)
     #
-    fct = ctypefunc.W_CTypeFunc(space, fargs, fresult, ellipsis)
+    fct = ctypefunc.W_CTypeFunc(space, fargs, w_fresult, ellipsis)
     return fct


More information about the pypy-commit mailing list