Author: Armin Rigo <[email protected]>
Branch: kill-someobject
Changeset: r57978:18f173be9b33
Date: 2012-10-10 17:42 +0200
http://bitbucket.org/pypy/pypy/changeset/18f173be9b33/
Log: Fix fix fix a bit more
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -58,10 +58,12 @@
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):
@@ -107,9 +109,6 @@
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)
@@ -207,10 +206,6 @@
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()))
@@ -346,9 +341,6 @@
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()))
@@ -552,7 +544,7 @@
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:
diff --git a/pypy/interpreter/test/test_gateway.py
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -439,25 +439,6 @@
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
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -1,5 +1,5 @@
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
diff --git a/pypy/module/posix/interp_posix.py
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1,4 +1,4 @@
-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
@@ -302,7 +302,7 @@
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.
diff --git a/pypy/objspace/std/frozensettype.py
b/pypy/objspace/std/frozensettype.py
--- a/pypy/objspace/std/frozensettype.py
+++ b/pypy/objspace/std/frozensettype.py
@@ -36,8 +36,7 @@
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):
diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py
--- a/pypy/objspace/std/inttype.py
+++ b/pypy/objspace/std/inttype.py
@@ -1,4 +1,5 @@
-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
@@ -88,7 +89,8 @@
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
@@ -198,9 +200,9 @@
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),
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -1,5 +1,6 @@
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
@@ -8,7 +9,8 @@
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:
@@ -126,12 +128,12 @@
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())
diff --git a/pypy/objspace/std/tupletype.py b/pypy/objspace/std/tupletype.py
--- a/pypy/objspace/std/tupletype.py
+++ b/pypy/objspace/std/tupletype.py
@@ -45,7 +45,7 @@
"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 = []
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit