Commits

Armin Rigo committed 18f173b

Fix fix fix a bit more

Comments (0)

Files changed (8)

pypy/interpreter/gateway.py

         if isinstance(el, str):
             getattr(self, "visit_%s" % (el,))(el, *args)
         elif isinstance(el, tuple):
-            if el[0] == 'self':
+            if el[0] == 'INTERNAL:self':
                 self.visit_self(el[1], *args)
             else:
-                self.visit_function(el, *args)
+                assert len(el) == 2    # 2nd arg is str that evals to 'default'
+                assert el[0] is W_Root    # for now
+                self.visit__W_Root(W_Root, *args)
         elif isinstance(el, type):
             for typ in self.bases_order:
                 if issubclass(el, typ):
         self.func = original_sig.func
         self.orig_arg = iter(original_sig.argnames).next
 
-    def visit_function(self, (func, cls), app_sig):
-        self.dispatch(cls, app_sig)
-
     def visit_self(self, cls, app_sig):
         self.visit__Wrappable(cls, app_sig)
 
     def scopenext(self):
         return "scope_w[%d]" % self.succ()
 
-    def visit_function(self, (func, cls)):
-        self.run_args.append("%s(%s)" % (self.use(func),
-                                         self.scopenext()))
-
     def visit_self(self, typ):
         self.run_args.append("space.descr_self_interp_w(%s, %s)" %
                              (self.use(typ), self.scopenext()))
         self.args.append(arg)
         return arg
 
-    def visit_function(self, (func, cls)):
-        raise FastFuncNotSupported
-
     def visit_self(self, typ):
         self.unwrap.append("space.descr_self_interp_w(%s, %s)" %
                            (self.use(typ), self.nextarg()))
             unwrap_spec = list(unwrap_spec)
             if descrmismatch is not None:
                 assert issubclass(self_type, Wrappable)
-                unwrap_spec[0] = ('self', self_type)
+                unwrap_spec[0] = ('INTERNAL:self', self_type)
                 self.descrmismatch_op = descrmismatch
                 self.descr_reqcls = self_type
             else:

pypy/interpreter/test/test_gateway.py

         raises(gateway.OperationError, space.call_function, w_app_g3_u,
                w(42))
 
-
-    def test_interp2app_unwrap_spec_func(self):
-        space = self.space
-        w = space.wrap
-        def g_id(space, w_x):
-            return w_x
-        l =[]
-        def checker(w_x):
-            l.append(w_x)
-            return w_x
-
-        app_g_id = gateway.interp2app_temp(g_id,
-                                           unwrap_spec=[gateway.ObjSpace,
-                                                        (checker, gateway.W_Root)])
-        w_app_g_id = space.wrap(app_g_id)
-        assert space.eq_w(space.call_function(w_app_g_id,w("foo")),w("foo"))
-        assert len(l) == 1
-        assert space.eq_w(l[0], w("foo"))
-
     def test_interp2app_classmethod(self):
         space = self.space
         w = space.wrap

pypy/module/_codecs/interp_codecs.py

 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.rlib.rstring import UnicodeBuilder
 from pypy.rlib.objectmodel import we_are_translated
 

pypy/module/posix/interp_posix.py

-from pypy.interpreter.gateway import unwrap_spec, NoneNotWrapped
+from pypy.interpreter.gateway import unwrap_spec
 from pypy.rlib import rposix, objectmodel, rurandom
 from pypy.rlib.objectmodel import specialize
 from pypy.rlib.rarithmetic import r_longlong
     def __init__(self, space):
         self.stat_float_times = True
 
-def stat_float_times(space, w_value=NoneNotWrapped):
+def stat_float_times(space, w_value=None):
     """stat_float_times([newval]) -> oldval
 
 Determine whether os.[lf]stat represents time stamps as float objects.

pypy/objspace/std/frozensettype.py

 
 register_all(vars(), globals())
 
-def descr__frozenset__new__(space, w_frozensettype,
-                            w_iterable=gateway.NoneNotWrapped):
+def descr__frozenset__new__(space, w_frozensettype, w_iterable=None):
     from pypy.objspace.std.setobject import W_FrozensetObject
     if (space.is_w(w_frozensettype, space.w_frozenset) and
         w_iterable is not None and type(w_iterable) is W_FrozensetObject):

pypy/objspace/std/inttype.py

-from pypy.interpreter import gateway, typedef
+from pypy.interpreter import typedef
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.buffer import Buffer
 from pypy.objspace.std.register_all import register_all
     from pypy.objspace.std.longobject import newlong
     return newlong(space, bigint)
 
-def descr__new__(space, w_inttype, w_x=0, w_base=gateway.NoneNotWrapped):
+@unwrap_spec(w_x = (W_Root, 'space.wrap(0)'))
+def descr__new__(space, w_inttype, w_x, w_base=None):
     from pypy.objspace.std.intobject import W_IntObject
     w_longval = None
     w_value = w_x     # 'x' is the keyword argument name in CPython
 the optional base.  It is an error to supply a base when converting a
 non-string. If the argument is outside the integer range a long object
 will be returned instead.''',
-    __new__ = gateway.interp2app(descr__new__),
-    conjugate = gateway.interp2app(descr_conjugate),
-    bit_length = gateway.interp2app(descr_bit_length),
+    __new__ = interp2app(descr__new__),
+    conjugate = interp2app(descr_conjugate),
+    bit_length = interp2app(descr_bit_length),
     numerator = typedef.GetSetProperty(descr_get_numerator),
     denominator = typedef.GetSetProperty(descr_get_denominator),
     real = typedef.GetSetProperty(descr_get_real),

pypy/objspace/std/longtype.py

 from pypy.interpreter.error import OperationError
-from pypy.interpreter import gateway, typedef
+from pypy.interpreter import typedef
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.strutil import string_to_bigint, ParseStringError
     return space.long(w_int)
 
 
-def descr__new__(space, w_longtype, w_x=0, w_base=gateway.NoneNotWrapped):
+@unwrap_spec(w_x = (W_Root, 'space.wrap(0)'))
+def descr__new__(space, w_longtype, w_x, w_base=None):
     from pypy.objspace.std.longobject import W_LongObject
     from pypy.rlib.rbigint import rbigint
     if space.config.objspace.std.withsmalllong:
 string representation of a floating point number!)  When converting a
 string, use the optional base.  It is an error to supply a base when
 converting a non-string.''',
-    __new__ = gateway.interp2app(descr__new__),
-    conjugate = gateway.interp2app(descr_conjugate),
+    __new__ = interp2app(descr__new__),
+    conjugate = interp2app(descr_conjugate),
     numerator = typedef.GetSetProperty(descr_get_numerator),
     denominator = typedef.GetSetProperty(descr_get_denominator),
     real = typedef.GetSetProperty(descr_get_real),
     imag = typedef.GetSetProperty(descr_get_imag),
-    bit_length = gateway.interp2app(bit_length),
+    bit_length = interp2app(bit_length),
 )
 long_typedef.registermethods(globals())

pypy/objspace/std/tupletype.py

                   "appears in the tuple")
 
 
-def descr__new__(space, w_tupletype, w_sequence=gateway.NoneNotWrapped):
+def descr__new__(space, w_tupletype, w_sequence=None):
     from pypy.objspace.std.tupleobject import W_TupleObject
     if w_sequence is None:
         tuple_w = []