[pypy-svn] r34248 - in pypy/dist/pypy: interpreter objspace objspace/std objspace/std/test
pedronis at codespeak.net
pedronis at codespeak.net
Sun Nov 5 17:10:55 CET 2006
Author: pedronis
Date: Sun Nov 5 17:10:51 2006
New Revision: 34248
Added:
pypy/dist/pypy/objspace/std/proxy_helpers.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/proxy_helpers.py
pypy/dist/pypy/objspace/std/proxyobject.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py
pypy/dist/pypy/objspace/std/test/test_proxy.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy.py
pypy/dist/pypy/objspace/std/test/test_proxy_function.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_function.py
pypy/dist/pypy/objspace/std/test/test_proxy_internals.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py
pypy/dist/pypy/objspace/std/test/test_proxy_iter.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_iter.py
pypy/dist/pypy/objspace/std/test/test_proxy_object.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_object.py
pypy/dist/pypy/objspace/std/transparent.py
- copied unchanged from r34239, pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py
Modified:
pypy/dist/pypy/interpreter/argument.py
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/gateway.py
pypy/dist/pypy/interpreter/pyopcode.py
pypy/dist/pypy/interpreter/typedef.py
pypy/dist/pypy/objspace/descroperation.py
pypy/dist/pypy/objspace/std/listobject.py
pypy/dist/pypy/objspace/std/model.py
pypy/dist/pypy/objspace/std/objspace.py
pypy/dist/pypy/objspace/std/stdtypedef.py
Log:
(pedronis, fijal)
merge the transparent-proxy branch.
Modified: pypy/dist/pypy/interpreter/argument.py
==============================================================================
--- pypy/dist/pypy/interpreter/argument.py (original)
+++ pypy/dist/pypy/interpreter/argument.py Sun Nov 5 17:10:51 2006
@@ -350,6 +350,11 @@
"Return a ([w1,w2...], {'kw':w3...}) pair."
self._unpack()
return self.arguments_w, self.kwds_w
+
+ def popfirst(self):
+ self._unpack()
+ return self.arguments_w[0], Arguments(self.space, self.arguments_w[1:],
+ kwds_w = self.kwds_w)
def _unpack(self):
"unpack the *arg and **kwd into w_arguments and kwds_w"
@@ -418,7 +423,7 @@
if not e.match(self.space, self.space.w_StopIteration):
raise
return None
-
+
### Parsing for function calls ###
def _match_signature(self, scope_w, argnames, has_vararg=False,
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Sun Nov 5 17:10:51 2006
@@ -27,6 +27,24 @@
return space.finditem(w_dict, w_attr)
return None
+ def setdictvalue(self, space, w_attr, w_value):
+ w_dict = self.getdict()
+ if w_dict is not None:
+ space.set_str_keyed_item(w_dict, w_attr, w_value)
+ return True
+ return False
+
+ def deldictvalue(self, space, w_name):
+ w_dict = self.getdict()
+ if w_dict is not None:
+ try:
+ space.delitem(w_dict, w_name)
+ return True
+ except OperationError, ex:
+ if not ex.match(space, space.w_KeyError):
+ raise
+ return False
+
def setdict(self, space, w_dict):
typename = space.type(self).getname(space, '?')
raise OperationError(space.w_TypeError,
@@ -74,6 +92,12 @@
def setslotvalue(self, index, w_val):
raise NotImplementedError
+ def descr_call_mismatch(self, space, opname, RequiredClass, args):
+ msg = "'%s' object expected, got '%s' instead" % (
+ RequiredClass.typedef.name,
+ self.getclass(space).getname(space, '?'))
+ raise OperationError(space.w_TypeError, space.wrap(msg))
+
# used by _weakref implemenation
def getweakref(self):
@@ -130,6 +154,9 @@
def __str__(self):
return self.msg
+class DescrMismatch(Exception):
+ pass
+
class ObjSpace(object):
"""Base class for the interpreter-level implementations of object spaces.
http://codespeak.net/pypy/dist/pypy/doc/objspace.html"""
@@ -454,6 +481,13 @@
return w_obj
return None
+ def descr_self_interp_w(self, RequiredClass, w_obj):
+ obj = self.interpclass_w(w_obj)
+ if not isinstance(obj, RequiredClass):
+ raise DescrMismatch()
+ return obj
+ descr_self_interp_w._annspecialcase_ = 'specialize:arg(1)'
+
def interp_w(self, RequiredClass, w_obj, can_be_None=False):
"""
Unwrap w_obj, checking that it is an instance of the required internal
Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py (original)
+++ pypy/dist/pypy/interpreter/gateway.py Sun Nov 5 17:10:51 2006
@@ -16,7 +16,7 @@
from pypy.interpreter import eval
from pypy.interpreter.function import Function, Method
from pypy.interpreter.baseobjspace import W_Root, ObjSpace, Wrappable
-from pypy.interpreter.baseobjspace import Wrappable, SpaceCache
+from pypy.interpreter.baseobjspace import Wrappable, SpaceCache, DescrMismatch
from pypy.interpreter.argument import Arguments, AbstractArguments
from pypy.tool.sourcetools import NiceCompile, compile2
@@ -55,7 +55,10 @@
if isinstance(el, str):
getattr(self, "visit_%s" % (el,))(el, *args)
elif isinstance(el, tuple):
- self.visit_function(el, *args)
+ if el[0] == 'self':
+ self.visit_self(el[1], *args)
+ else:
+ self.visit_function(el, *args)
else:
for typ in self.bases_order:
if issubclass(el, typ):
@@ -100,6 +103,9 @@
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 visit__Wrappable(self, el, app_sig):
name = el.__name__
@@ -170,6 +176,10 @@
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()))
+
def visit__Wrappable(self, typ):
self.run_args.append("space.interp_w(%s, %s)" % (self.use(typ),
self.scopenext()))
@@ -275,6 +285,10 @@
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()))
+
def visit__Wrappable(self, typ):
self.unwrap.append("space.interp_w(%s, %s)" % (self.use(typ),
self.nextarg()))
@@ -334,13 +348,16 @@
class BuiltinCode(eval.Code):
"The code object implementing a built-in (interpreter-level) hook."
hidden_applevel = True
+ descrmismatch_op = None
+ descr_reqcls = None
# When a BuiltinCode is stored in a Function object,
# you get the functionality of CPython's built-in function type.
NOT_RPYTHON_ATTRIBUTES = ['_bltin', '_unwrap_spec']
- def __init__(self, func, unwrap_spec = None, self_type = None):
+ def __init__(self, func, unwrap_spec = None, self_type = None,
+ descrmismatch=None):
"NOT_RPYTHON"
# 'implfunc' is the interpreter-level function.
# Note that this uses a lot of (construction-time) introspection.
@@ -375,7 +392,17 @@
if self_type:
assert unwrap_spec[0] == 'self',"self_type without 'self' spec element"
unwrap_spec = list(unwrap_spec)
- unwrap_spec[0] = self_type
+ if descrmismatch is not None:
+ assert issubclass(self_type, Wrappable)
+ unwrap_spec[0] = ('self', self_type)
+ self.descrmismatch_op = descrmismatch
+ self.descr_reqcls = self_type
+ else:
+ unwrap_spec[0] = self_type
+ else:
+ assert descrmismatch is None, (
+ "descrmismatch without a self-type specified")
+
orig_sig = Signature(func, argnames, varargname, kwargname)
app_sig = Signature(func)
@@ -433,7 +460,12 @@
raise OperationError(space.w_MemoryError, space.w_None)
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
- space.wrap("internal error: " + str(e)))
+ space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return scope_w[0].descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ args)
if w_result is None:
w_result = space.w_None
return w_result
@@ -453,6 +485,11 @@
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return args.firstarg().descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ args)
if w_result is None:
w_result = space.w_None
return w_result
@@ -475,6 +512,11 @@
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return args.firstarg().descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ args)
if w_result is None:
w_result = space.w_None
return w_result
@@ -486,8 +528,8 @@
except KeyboardInterrupt:
raise OperationError(space.w_KeyboardInterrupt, space.w_None)
except MemoryError:
- raise OperationError(space.w_MemoryError, space.w_None)
- except RuntimeError, e:
+ raise OperationError(space.w_MemoryError, space.w_None)
+ except (RuntimeError, DescrMismatch), e:
raise OperationError(space.w_RuntimeError,
space.wrap("internal error: " + str(e)))
if w_result is None:
@@ -504,7 +546,12 @@
raise OperationError(space.w_MemoryError, space.w_None)
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
- space.wrap("internal error: " + str(e)))
+ space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return w1.descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ Arguments(space, [w1]))
if w_result is None:
w_result = space.w_None
return w_result
@@ -520,6 +567,11 @@
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return w1.descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ Arguments(space, [w1, w2]))
if w_result is None:
w_result = space.w_None
return w_result
@@ -534,7 +586,12 @@
raise OperationError(space.w_MemoryError, space.w_None)
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
- space.wrap("internal error: " + str(e)))
+ space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return w1.descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ Arguments(space, [w1, w2, w3]))
if w_result is None:
w_result = space.w_None
return w_result
@@ -549,7 +606,13 @@
raise OperationError(space.w_MemoryError, space.w_None)
except RuntimeError, e:
raise OperationError(space.w_RuntimeError,
- space.wrap("internal error: " + str(e)))
+ space.wrap("internal error: " + str(e)))
+ except DescrMismatch, e:
+ return w1.descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ Arguments(space,
+ [w1, w2, w3, w4]))
if w_result is None:
w_result = space.w_None
return w_result
@@ -569,7 +632,8 @@
NOT_RPYTHON_ATTRIBUTES = ['_staticdefs']
- def __init__(self, f, app_name=None, unwrap_spec = None):
+ def __init__(self, f, app_name=None, unwrap_spec = None,
+ descrmismatch=None):
"NOT_RPYTHON"
Wrappable.__init__(self)
# f must be a function whose name does NOT start with 'app_'
@@ -584,7 +648,9 @@
raise ValueError, ("function name %r suspiciously starts "
"with 'app_'" % f.func_name)
app_name = f.func_name
- self._code = BuiltinCode(f, unwrap_spec=unwrap_spec, self_type = self_type)
+ self._code = BuiltinCode(f, unwrap_spec=unwrap_spec,
+ self_type = self_type,
+ descrmismatch=descrmismatch)
self.__name__ = f.func_name
self.name = app_name
self._staticdefs = list(f.func_defaults or ())
Modified: pypy/dist/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyopcode.py (original)
+++ pypy/dist/pypy/interpreter/pyopcode.py Sun Nov 5 17:10:51 2006
@@ -351,7 +351,8 @@
raise operror
else:
tb = space.interpclass_w(w_traceback)
- if not isinstance(tb, pytraceback.PyTraceback):
+ if tb is None or not space.is_true(space.isinstance(tb,
+ space.gettypeobject(pytraceback.PyTraceback.typedef))):
raise OperationError(space.w_TypeError,
space.wrap("raise: arg 3 must be a traceback or None"))
operror.application_traceback = tb
Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py (original)
+++ pypy/dist/pypy/interpreter/typedef.py Sun Nov 5 17:10:51 2006
@@ -5,7 +5,8 @@
import py
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.argument import Arguments
-from pypy.interpreter.baseobjspace import Wrappable, W_Root, ObjSpace
+from pypy.interpreter.baseobjspace import Wrappable, W_Root, ObjSpace, \
+ DescrMismatch
from pypy.interpreter.error import OperationError
from pypy.tool.sourcetools import compile2, func_with_new_name
from pypy.rlib.objectmodel import instantiate
@@ -242,7 +243,7 @@
assert issubclass(cls, Wrappable)
source = """
def descr_typecheck_%(name)s(space, w_obj, %(extra)s):
- obj = space.interp_w(%(cls_name)s, w_obj)
+ obj = space.descr_self_interp_w(%(cls_name)s, w_obj)
return %(name)s(space, obj, %(extra)s)
"""
miniglobals[cls_name] = cls
@@ -295,6 +296,7 @@
self.fset = fset
self.fdel = fdel
self.doc = doc
+ self.reqcls = cls
self.name = '<generic property>'
self.objclass_getter = objclass_getter
@@ -307,7 +309,12 @@
#print property, w_obj, w_cls
return space.wrap(property)
else:
- return property.fget(space, w_obj)
+ try:
+ return property.fget(space, w_obj)
+ except DescrMismatch, e:
+ return w_obj.descr_call_mismatch(space, '__getattribute__',\
+ property.reqcls, Arguments(space, [w_obj,
+ space.wrap(property.name)]))
def descr_property_set(space, property, w_obj, w_value):
"""property.__set__(obj, value)
@@ -316,7 +323,12 @@
if fset is None:
raise OperationError(space.w_TypeError,
space.wrap("readonly attribute"))
- fset(space, w_obj, w_value)
+ try:
+ fset(space, w_obj, w_value)
+ except DescrMismatch, e:
+ w_obj.descr_call_mismatch(space, '__setattr__',\
+ property.reqcls, Arguments(space, [w_obj,
+ space.wrap(property.name), w_value]))
def descr_property_del(space, property, w_obj):
"""property.__delete__(obj)
@@ -325,7 +337,12 @@
if fdel is None:
raise OperationError(space.w_AttributeError,
space.wrap("cannot delete attribute"))
- fdel(space, w_obj)
+ try:
+ fdel(space, w_obj)
+ except DescrMismatch, e:
+ w_obj.descr_call_mismatch(space, '__delattr__',\
+ property.reqcls, Arguments(space, [w_obj,
+ space.wrap(property.name)]))
def descr_get_objclass(space, property):
return property.objclass_getter(space)
@@ -583,9 +600,10 @@
Function.typedef = TypeDef("function",
__new__ = interp2app(Function.descr_method__new__.im_func),
__call__ = interp2app(Function.descr_function_call,
- unwrap_spec=['self', Arguments]),
+ unwrap_spec=['self', Arguments],
+ descrmismatch='__call__'),
__get__ = interp2app(descr_function_get),
- __repr__ = interp2app(Function.descr_function_repr),
+ __repr__ = interp2app(Function.descr_function_repr, descrmismatch='__repr__'),
__reduce__ = interp2app(Function.descr_function__reduce__,
unwrap_spec=['self', ObjSpace]),
__setstate__ = interp2app(Function.descr_function__setstate__,
@@ -650,8 +668,10 @@
GeneratorIterator.typedef = TypeDef("generator",
__reduce__ = interp2app(GeneratorIterator.descr__reduce__,
unwrap_spec=['self', ObjSpace]),
- next = interp2app(GeneratorIterator.descr_next),
- __iter__ = interp2app(GeneratorIterator.descr__iter__),
+ next = interp2app(GeneratorIterator.descr_next,
+ descrmismatch='next'),
+ __iter__ = interp2app(GeneratorIterator.descr__iter__,
+ descrmismatch='__iter__'),
gi_running = interp_attrproperty('running', cls=GeneratorIterator),
gi_frame = interp_attrproperty('frame', cls=GeneratorIterator),
__weakref__ = make_weakref_descr(GeneratorIterator),
Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py (original)
+++ pypy/dist/pypy/objspace/descroperation.py Sun Nov 5 17:10:51 2006
@@ -35,9 +35,7 @@
if space.is_data_descr(w_descr):
space.set(w_descr, w_obj, w_value)
return
- w_dict = w_obj.getdict()
- if w_dict is not None:
- space.set_str_keyed_item(w_dict, w_name, w_value)
+ if w_obj.setdictvalue(space, w_name, w_value):
return
raiseattrerror(space, w_obj, name, w_descr)
@@ -48,14 +46,8 @@
if space.is_data_descr(w_descr):
space.delete(w_descr, w_obj)
return
- w_dict = w_obj.getdict()
- if w_dict is not None:
- try:
- space.delitem(w_dict, w_name)
- return
- except OperationError, ex:
- if not ex.match(space, space.w_KeyError):
- raise
+ if w_obj.deldictvalue(space, w_name):
+ return
raiseattrerror(space, w_obj, name, w_descr)
def descr__init__(space, w_obj, __args__):
@@ -404,9 +396,11 @@
if space.is_w(w_obj2, space.w_None):
return space.wrap(1)
if space.is_w(w_typ1, w_typ2):
+ #print "WARNING, comparison by address!"
w_id1 = space.id(w_obj1)
w_id2 = space.id(w_obj2)
else:
+ #print "WARNING, comparison by address!"
w_id1 = space.id(w_typ1)
w_id2 = space.id(w_typ2)
if space.is_true(space.lt(w_id1, w_id2)):
@@ -451,6 +445,9 @@
left, right = specialnames
op = getattr(operator, left)
def comparison_impl(space, w_obj1, w_obj2):
+ #from pypy.objspace.std.tlistobject import W_TransparentList
+ #if isinstance(w_obj1, W_TransparentList):
+ # import pdb;pdb.set_trace()
w_typ1 = space.type(w_obj1)
w_typ2 = space.type(w_obj2)
w_left_src, w_left_impl = space.lookup_in_type_where(w_typ1, left)
@@ -523,9 +520,9 @@
l = ["space.is_true(space.isinstance(w_result, %s))" % x
for x in checkerspec]
checker = " or ".join(l)
- source = """if 1:
+ source = """if 1:
def %(targetname)s(space, w_obj):
- w_impl = space.lookup(w_obj, %(specialname)r)
+ w_impl = space.lookup(w_obj, %(specialname)r)
if w_impl is None:
raise OperationError(space.w_TypeError,
space.wrap("operand does not support unary %(targetname)s"))
Modified: pypy/dist/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/listobject.py (original)
+++ pypy/dist/pypy/objspace/std/listobject.py Sun Nov 5 17:10:51 2006
@@ -78,6 +78,16 @@
def add__List_List(space, w_list1, w_list2):
return W_ListObject(w_list1.wrappeditems + w_list2.wrappeditems)
+#def radd__List_List(space, w_list1, w_list2):
+# return W_ListObject(w_list2.wrappeditems + w_list1.wrappeditems)
+
+##def add__List_ANY(space, w_list, w_any):
+## if space.is_true(space.isinstance(w_any, space.w_list)):
+## items1_w = w_list.wrappeditems
+## items2_w = space.unpackiterable(w_any)
+## return W_ListObject(items1_w + items2_w)
+## raise FailedToImplement
+
def inplace_add__List_ANY(space, w_list1, w_iterable2):
list_extend__List_ANY(space, w_list1, w_iterable2)
return w_list1
@@ -109,26 +119,37 @@
def eq__List_List(space, w_list1, w_list2):
# needs to be safe against eq_w() mutating the w_lists behind our back
- if len(w_list1.wrappeditems) != len(w_list2.wrappeditems):
+ items1_w = w_list1.wrappeditems
+ items2_w = w_list2.wrappeditems
+ return equal_wrappeditems(space, items1_w, items2_w)
+
+def equal_wrappeditems(space, items1_w, items2_w):
+ if len(items1_w) != len(items2_w):
return space.w_False
i = 0
- while i < len(w_list1.wrappeditems) and i < len(w_list2.wrappeditems):
- if not space.eq_w(w_list1.wrappeditems[i], w_list2.wrappeditems[i]):
+ while i < len(items1_w) and i < len(items2_w):
+ if not space.eq_w(items1_w[i], items2_w[i]):
return space.w_False
i += 1
- return space.newbool(len(w_list1.wrappeditems) == len(w_list2.wrappeditems))
+ return space.w_True
+ #return space.newbool(len(w_list1.wrappeditems) == len(w_list2.wrappeditems))
+
+##def eq__List_ANY(space, w_list1, w_any):
+## if space.is_true(space.isinstance(w_any, space.w_list)):
+## items1_w = w_list1.wrappeditems
+## items2_w = space.unpackiterable(w_any)
+## return equal_wrappeditems(space, items1_w, items2_w)
+## raise FailedToImplement
def _min(a, b):
if a < b:
return a
return b
-def lt__List_List(space, w_list1, w_list2):
+def lessthan_unwrappeditems(space, items1_w, items2_w):
# needs to be safe against eq_w() mutating the w_lists behind our back
# Search for the first index where items are different
i = 0
- items1_w = w_list1.wrappeditems
- items2_w = w_list2.wrappeditems
while i < len(items1_w) and i < len(items2_w):
w_item1 = items1_w[i]
w_item2 = items2_w[i]
@@ -138,13 +159,11 @@
# No more items to compare -- compare sizes
return space.newbool(len(items1_w) < len(items2_w))
-def gt__List_List(space, w_list1, w_list2):
+def greaterthan_unwrappeditems(space, items1_w, items2_w):
# needs to be safe against eq_w() mutating the w_lists behind our back
# Search for the first index where items are different
i = 0
- items1_w = w_list1.wrappeditems
- items2_w = w_list2.wrappeditems
- while i < len(w_list1.wrappeditems) and i < len(w_list2.wrappeditems):
+ while i < len(items1_w) and i < len(items2_w):
w_item1 = items1_w[i]
w_item2 = items2_w[i]
if not space.eq_w(w_item1, w_item2):
@@ -153,6 +172,29 @@
# No more items to compare -- compare sizes
return space.newbool(len(items1_w) > len(items2_w))
+def lt__List_List(space, w_list1, w_list2):
+ return lessthan_unwrappeditems(space, w_list1.wrappeditems,
+ w_list2.wrappeditems)
+
+##def lt__List_ANY(space, w_list1, w_any):
+## # XXX: Implement it not unpacking all the elements
+## if space.is_true(space.isinstance(w_any, space.w_list)):
+## items1_w = w_list1.wrappeditems
+## items2_w = space.unpackiterable(w_any)
+## return lessthan_unwrappeditems(space, items1_w, items2_w)
+## raise FailedToImplement
+
+def gt__List_List(space, w_list1, w_list2):
+ return greaterthan_unwrappeditems(space, w_list1.wrappeditems,
+ w_list2.wrappeditems)
+
+##def gt__List_ANY(space, w_list1, w_any):
+## # XXX: Implement it not unpacking all the elements
+## if space.is_true(space.isinstance(w_any, space.w_list)):
+## items1_w = w_list1.wrappeditems
+## items2_w = space.unpackiterable(w_any)
+## return greaterthan_unwrappeditems(space, items1_w, items2_w)
+## raise FailedToImplement
def delitem__List_ANY(space, w_list, w_idx):
idx = space.int_w(w_idx)
Modified: pypy/dist/pypy/objspace/std/model.py
==============================================================================
--- pypy/dist/pypy/objspace/std/model.py (original)
+++ pypy/dist/pypy/objspace/std/model.py Sun Nov 5 17:10:51 2006
@@ -18,6 +18,8 @@
"dictmultiobject.W_DictMultiIterObject"],
"withrangelist" : ["rangeobject.W_RangeListObject",
"rangeobject.W_RangeIterObject"],
+ "withtproxy" : ["proxyobject.W_TransparentList",
+ "proxyobject.W_TransparentDict"],
}
class StdTypeModel:
@@ -74,6 +76,7 @@
from pypy.objspace.std import unicodeobject
from pypy.objspace.std import dictproxyobject
from pypy.objspace.std import rangeobject
+ from pypy.objspace.std import proxyobject
from pypy.objspace.std import fake
import pypy.objspace.std.default # register a few catch-all multimethods
@@ -137,6 +140,7 @@
# register the order in which types are converted into each others
# when trying to dispatch multimethods.
# XXX build these lists a bit more automatically later
+
if config.objspace.std.withsmallint:
self.typeorder[boolobject.W_BoolObject] += [
(smallintobject.W_SmallIntObject, boolobject.delegate_Bool2SmallInt),
@@ -195,6 +199,9 @@
# put W_Root everywhere
self.typeorder[W_Root] = []
for type in self.typeorder:
+ from pypy.objspace.std import stdtypedef
+ if type is not W_Root and isinstance(type.typedef, stdtypedef.StdTypeDef):
+ self.typeorder[type].append((type.typedef.any, None))
self.typeorder[type].append((W_Root, None))
# ____________________________________________________________
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Sun Nov 5 17:10:51 2006
@@ -132,6 +132,12 @@
# final setup
self.setup_builtin_modules()
+ # Adding transparent proxy call
+ if self.config.objspace.std.withtproxy:
+ from pypy.objspace.std.transparent import app_proxy
+
+ self.setitem(self.builtin.w_dict, self.wrap('proxy'),
+ self.wrap(app_proxy))
def enable_old_style_classes_as_default_metaclass(self):
self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
Modified: pypy/dist/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/dist/pypy/objspace/std/stdtypedef.py Sun Nov 5 17:10:51 2006
@@ -20,6 +20,7 @@
def __init__(self, __name, __base=None, **rawdict):
"NOT_RPYTHON: initialization-time only."
TypeDef.__init__(self, __name, __base, **rawdict)
+ self.any = type("W_Any"+__name.title(), (baseobjspace.W_Root,), {'typedef': self})
self.local_multimethods = []
def registermethods(self, namespace):
More information about the Pypy-commit
mailing list