Commits

Amaury Forgeot d'Arc committed 68c34e4

kill most unwrap_spec in objspace

  • Participants
  • Parent commits 2211559
  • Branches improve-unwrap_spec

Comments (0)

Files changed (12)

pypy/objspace/std/bytearraytype.py

         data.append(value)
     return data
 
-@gateway.unwrap_spec(gateway.ObjSpace, gateway.W_Root)
 def descr_bytearray__reduce__(space, w_self):
     from pypy.objspace.std.bytearrayobject import W_BytearrayObject
     assert isinstance(w_self, W_BytearrayObject)
         return val - 87
     return -1
 
-@gateway.unwrap_spec(ObjSpace, W_Root, W_Root)
 def descr_fromhex(space, w_type, w_hexstring):
     "bytearray.fromhex(string) -> bytearray\n\nCreate a bytearray object "
     "from a string of hexadecimal numbers.\nSpaces between two numbers are "
 bytearray(sequence) -> bytearray initialized from sequence\'s items
 
 If the argument is a bytearray, the return value is the same object.''',
-    __new__ = gateway.interp2app(descr__new__, unwrap_spec=[gateway.ObjSpace,
-                                               gateway.W_Root,
-                                               gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = None,
     __reduce__ = gateway.interp2app(descr_bytearray__reduce__),
     fromhex = gateway.interp2app(descr_fromhex, as_classmethod=True)

pypy/objspace/std/dicttype.py

-from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.mixedmodule import MixedModule
 from pypy.interpreter import gateway
 
 register_all(vars(), globals())
 
-@gateway.unwrap_spec(ObjSpace, W_Root, W_Root, W_Root)
 def descr_fromkeys(space, w_type, w_keys, w_fill=None):
     from pypy.objspace.std.dictmultiobject import W_DictMultiObject
     if w_fill is None:
         d[k] = v
 dict(**kwargs) -> new dictionary initialized with the name=value pairs
     in the keyword argument list.  For example:  dict(one=1, two=2)''',
-    __new__ = gateway.interp2app(descr__new__,
-                                 unwrap_spec=
-                                 [gateway.ObjSpace,
-                                  gateway.W_Root,gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = None,
     __repr__ = gateway.interp2app(descr_repr),
     fromkeys = gateway.interp2app(descr_fromkeys, as_classmethod=True),
 
 
 dictiter_typedef = StdTypeDef("dictionaryiterator",
-    __reduce__ = gateway.interp2app(descr_dictiter__reduce__,
-                           unwrap_spec=[gateway.W_Root, gateway.ObjSpace]),
+    __reduce__ = gateway.interp2app(descr_dictiter__reduce__),
     )
 
 # ____________________________________________________________

pypy/objspace/std/fake.py

         return w_obj
     fake__new__.func_name = "fake__new__" + cpy_type.__name__
 
-    kw['__new__'] = gateway.interp2app(fake__new__,
-                                       unwrap_spec=[baseobjspace.ObjSpace,
-                                                    baseobjspace.W_Root,
-                                                    argument.Arguments])
+    kw['__new__'] = gateway.interp2app(fake__new__)
     if cpy_type.__base__ is not object and not issubclass(cpy_type, Exception):
         assert cpy_type.__base__ is basestring, cpy_type
         from pypy.objspace.std.basestringtype import basestring_typedef
     def __init__(self, space, d):
         self.name = d.__name__
 
-    def descr_descriptor_get(space, descr, w_obj, w_cls=None):
+    def descr_descriptor_get(self, space, w_obj, w_cls=None):
         # XXX HAAAAAAAAAAAACK (but possibly a good one)
         if (space.is_w(w_obj, space.w_None)
             and not space.is_w(w_cls, space.type(space.w_None))):
-            #print descr, w_obj, w_cls
-            return space.wrap(descr)
+            #print self, w_obj, w_cls
+            return space.wrap(self)
         else:
-            name = descr.name
+            name = self.name
             obj = space.unwrap(w_obj)
             try:
                 val = getattr(obj, name)  # this gives a "not RPython" warning
                 raise
             return space.wrap(val)
 
-    def descr_descriptor_set(space, descr, w_obj, w_value):
-        name = descr.name
+    def descr_descriptor_set(self, space, w_obj, w_value):
+        name = self.name
         obj = space.unwrap(w_obj)
         val = space.unwrap(w_value)
         try:
         except:
             wrap_exception(space)
 
-    def descr_descriptor_del(space, descr, w_obj):
-        name = descr.name
+    def descr_descriptor_del(self, space, w_obj):
+        name = self.name
         obj = space.unwrap(w_obj)
         try:
             delattr(obj, name)
 
 W_FakeDescriptor.typedef = TypeDef(
     "FakeDescriptor",
-    __get__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_get.im_func,
-                         unwrap_spec = [baseobjspace.ObjSpace, W_FakeDescriptor,
-                                        baseobjspace.W_Root,
-                                        baseobjspace.W_Root]),
-    __set__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_set.im_func,
-                         unwrap_spec = [baseobjspace.ObjSpace, W_FakeDescriptor,
-                                        baseobjspace.W_Root, baseobjspace.W_Root]),
-    __delete__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_del.im_func,
-                            unwrap_spec = [baseobjspace.ObjSpace, W_FakeDescriptor,
-                                           baseobjspace.W_Root]),
+    __get__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_get),
+    __set__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_set),
+    __delete__ = gateway.interp2app(W_FakeDescriptor.descr_descriptor_del),
     )
 
 if hasattr(file, 'softspace'):    # CPython only

pypy/objspace/std/floattype.py

 
 _double_format, _float_format = detect_floatformat()
 
+@gateway.unwrap_spec(kind=str)
 def descr___getformat__(space, w_cls, kind):
     if kind == "float":
         return space.wrap(_float_format)
         i = co_end - 1 - j
     return _hex_from_char(s[i])
 
+@gateway.unwrap_spec(s=str)
 def descr_fromhex(space, w_cls, s):
     length = len(s)
     i = 0
 Convert a string or number to a floating point number, if possible.''',
     __new__ = gateway.interp2app(descr__new__),
     __getformat__ = gateway.interp2app(descr___getformat__,
-                                       unwrap_spec=[ObjSpace, W_Root, str],
                                        as_classmethod=True),
     fromhex = gateway.interp2app(descr_fromhex,
-                                 unwrap_spec=[ObjSpace, W_Root, str],
                                  as_classmethod=True),
     real = typedef.GetSetProperty(descr_get_real),
     imag = typedef.GetSetProperty(descr_get_imag),

pypy/objspace/std/itertype.py

 supply its own iterator, or be a sequence.
 In the second form, the callable is called until it returns the sentinel.''',
 
-    __reduce__ = gateway.interp2app(descr_seqiter__reduce__,
-                           unwrap_spec=[gateway.W_Root, gateway.ObjSpace]),
+    __reduce__ = gateway.interp2app(descr_seqiter__reduce__),
     )
 iter_typedef.acceptable_as_base_class = False
 
 reverse_iter_typedef = StdTypeDef("reversesequenceiterator",
 
-    __reduce__ = gateway.interp2app(descr_reverseseqiter__reduce__,
-                           unwrap_spec=[gateway.W_Root, gateway.ObjSpace]),
+    __reduce__ = gateway.interp2app(descr_reverseseqiter__reduce__),
     )
 reverse_iter_typedef.acceptable_as_base_class = False

pypy/objspace/std/listtype.py

 list_typedef = StdTypeDef("list",
     __doc__ = '''list() -> new list
 list(sequence) -> new list initialized from sequence's items''',
-    __new__ = gateway.interp2app(descr__new__, unwrap_spec=[gateway.ObjSpace,
-                                               gateway.W_Root,
-                                               gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = None,
     )
 list_typedef.registermethods(globals())

pypy/objspace/std/objecttype.py

 def descr__init__(space, w_obj, __args__):
     pass
 
+@gateway.unwrap_spec(proto=int)
 def descr__reduce__(space, w_obj, proto=0):
     if proto >= 2:
         return reduce_2(space, w_obj)
     w_proto = space.wrap(proto)
     return reduce_1(space, w_obj, w_proto)
 
+@gateway.unwrap_spec(proto=int)
 def descr__reduce_ex__(space, w_obj, proto=0):
     w_st_reduce = space.wrap('__reduce__')
     w_reduce = space.findattr(w_obj, w_st_reduce)
     __repr__ = gateway.interp2app(descr__repr__),
     __class__ = GetSetProperty(descr__class__, descr_set___class__),
     __doc__ = '''The most base type''',
-    __new__ = gateway.interp2app(descr__new__,
-    unwrap_spec = [gateway.ObjSpace,gateway.W_Root,gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = gateway.interp2app(default_identity_hash),
-    __reduce_ex__ = gateway.interp2app(descr__reduce_ex__,
-                                  unwrap_spec=[gateway.ObjSpace,gateway.W_Root,int]),
-    __reduce__ = gateway.interp2app(descr__reduce__,
-                                  unwrap_spec=[gateway.ObjSpace,gateway.W_Root,int]),
-    __format__ = gateway.interp2app(descr___format__, unwrap_spec=[ObjSpace,
-                                   gateway.W_Root, gateway.W_Root]),
-    __subclasshook__ = gateway.interp2app(descr___subclasshook__, unwrap_spec=
-    [ObjSpace, Arguments], as_classmethod=True),
-    __init__ = gateway.interp2app(descr__init__,
-                                  unwrap_spec=[gateway.ObjSpace,gateway.W_Root,gateway.Arguments]),
+    __reduce_ex__ = gateway.interp2app(descr__reduce_ex__),
+    __reduce__ = gateway.interp2app(descr__reduce__),
+    __format__ = gateway.interp2app(descr___format__),
+    __subclasshook__ = gateway.interp2app(descr___subclasshook__),
+    __init__ = gateway.interp2app(descr__init__),
     )

pypy/objspace/std/settype.py

     __doc__ = """set(iterable) --> set object
 
 Build an unordered collection.""",
-    __new__ = gateway.interp2app(descr__new__, unwrap_spec=[gateway.ObjSpace,
-                                                            gateway.W_Root,
-                                                            gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = None,
     )
 

pypy/objspace/std/slicetype.py

 
 # ____________________________________________________________
 
+@gateway.unwrap_spec(args_w='args_w')
 def descr__new__(space, w_slicetype, args_w):
     from pypy.objspace.std.sliceobject import W_SliceObject
     w_start = space.w_None
     w_obj = space.allocate_instance(W_SliceObject, w_slicetype)
     W_SliceObject.__init__(w_obj, w_start, w_stop, w_step)
     return w_obj
-#
-descr__new__.unwrap_spec = [baseobjspace.ObjSpace, baseobjspace.W_Root,
-                            'args_w']
 
 def descr__reduce__(space, w_self):
     from pypy.objspace.std.sliceobject import W_SliceObject
                         w_self.w_stop,
                         w_self.w_step]),
         ])
-descr__reduce__.unwrap_spec = [baseobjspace.ObjSpace, baseobjspace.W_Root]
 
 # ____________________________________________________________
 

pypy/objspace/std/transparent.py

         return w_object.w_controller
     return None
 
-app_proxy = gateway.interp2app(proxy, unwrap_spec=[gateway.ObjSpace, gateway.W_Root, \
-    gateway.W_Root])
-app_proxy_controller = gateway.interp2app(proxy_controller, unwrap_spec=[gateway.ObjSpace, gateway.W_Root])
+app_proxy = gateway.interp2app(proxy)
+app_proxy_controller = gateway.interp2app(proxy_controller)

pypy/objspace/taint.py

         return w_obj
     else:
         return W_Tainted(w_obj)
-taint.unwrap_spec = [gateway.W_Root]
 app_taint = gateway.interp2app(taint)
 
 def is_tainted(space, w_obj):
 
 # ____________________________________________________________
 
+@gateway.unwrap_spec(args_w='args_w')
 def taint_atomic_function(space, w_func, args_w):
     newargs_w = []
     tainted = False
         w_res = taint(w_res)
     return w_res
 
-app_taint_atomic_function = gateway.interp2app(
-    taint_atomic_function,
-    unwrap_spec=[gateway.ObjSpace, gateway.W_Root, 'args_w'])
+app_taint_atomic_function = gateway.interp2app(taint_atomic_function)
 
 def taint_atomic(space, w_callable):
     """decorator to make a callable "taint-atomic": if the function is called
 
 executioncontext.ExecutionContext.taint_debug = 0
 
+@gateway.unwrap_spec(level=int)
 def taint_debug(space, level):
     """Set the debug level. If the debug level is greater than 0, the creation
 of taint bombs will print debug information. For debugging purposes
 only!"""
     space.getexecutioncontext().taint_debug = level
-app_taint_debug = gateway.interp2app(taint_debug,
-                                     unwrap_spec=[gateway.ObjSpace, int])
+app_taint_debug = gateway.interp2app(taint_debug)
 
 def taint_look(space, w_obj):
     """Print some info about the taintedness of an object. For debugging

pypy/objspace/thunk.py

     """thunk(f, *args, **kwds) -> an object that behaves like the
     result of the call f(*args, **kwds).  The call is performed lazily."""
     return W_Thunk(w_callable, __args__)
-app_thunk = gateway.interp2app(thunk, unwrap_spec=[baseobjspace.W_Root,
-                                                   argument.Arguments])
+app_thunk = gateway.interp2app(thunk)
 
 def is_thunk(space, w_obj):
     """Check if an object is a thunk that has not been computed yet."""