[pypy-svn] r4927 - in pypy/branch/src-newobjectmodel/pypy/objspace: . std
mwh at codespeak.net
mwh at codespeak.net
Fri Jun 4 21:15:38 CEST 2004
Author: mwh
Date: Fri Jun 4 21:15:37 2004
New Revision: 4927
Modified:
pypy/branch/src-newobjectmodel/pypy/objspace/descroperation.py
pypy/branch/src-newobjectmodel/pypy/objspace/std/objspace.py
pypy/branch/src-newobjectmodel/pypy/objspace/std/stdtypedef.py
pypy/branch/src-newobjectmodel/pypy/objspace/std/stringobject.py
pypy/branch/src-newobjectmodel/pypy/objspace/std/typeobject.py
pypy/branch/src-newobjectmodel/pypy/objspace/std/typetype.py
Log:
fixity fix
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/descroperation.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/descroperation.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/descroperation.py Fri Jun 4 21:15:37 2004
@@ -201,7 +201,7 @@
w_right_impl = None
else:
w_right_impl = space.lookup(w_obj2,'__rpow__')
- if space.issubtype(w_typ1,w_typ2):
+ if space.is_true(space.issubtype(w_typ1,w_typ2)):
w_obj1,w_obj2 = w_obj2,w_obj1
w_left_impl,w_right_impl = w_right_impl,w_left_impl
if w_left_impl is not None:
@@ -255,7 +255,7 @@
w_right_impl = None
else:
w_right_impl = space.lookup(w_obj2,'__cmp__')
- if space.issubtype(w_typ1,w_typ2):
+ if space.is_true(space.issubtype(w_typ1,w_typ2)):
w_obj1,w_obj2 = w_obj2,w_obj1
w_left_impl,w_right_impl = w_right_impl,w_left_impl
do_neg1,do_neg2 = do_neg2,do_neg1
@@ -296,7 +296,7 @@
w_right_impl = None
else:
w_right_impl = space.lookup(w_obj2,right)
- if space.issubtype(w_typ1,w_typ2):
+ if space.is_true(space.issubtype(w_typ1,w_typ2)):
w_obj1,w_obj2 = w_obj2,w_obj1
w_left_impl,w_right_impl = w_right_impl,w_left_impl
@@ -324,7 +324,7 @@
w_right_impl = None
else:
w_right_impl = space.lookup(w_obj2,right)
- if space.issubtype(w_typ1,w_typ2):
+ if space.is_true(space.issubtype(w_typ1,w_typ2)):
w_obj1,w_obj2 = w_obj2,w_obj1
w_left_impl,w_right_impl = w_right_impl,w_left_impl
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/objspace.py Fri Jun 4 21:15:37 2004
@@ -45,15 +45,15 @@
"Import here the types you want to have appear in __builtin__."
from objecttype import object_typedef
- #from booltype import W_BoolType
+ from booltype import bool_typedef
from inttype import int_typedef
- #from floattype import W_FloatType
- #from tupletype import W_TupleType
- #from listtype import W_ListType
- #from dicttype import W_DictType
- #from stringtype import W_StringType
+ from floattype import float_typedef
+ from tupletype import tuple_typedef
+ from listtype import list_typedef
+ from dicttype import dict_typedef
+ from stringtype import str_typedef
from typetype import type_typedef
- #from slicetype import W_SliceType
+ from slicetype import slice_typedef
return [value for key, value in result.__dict__.items()
if not key.startswith('_')] # don't look
@@ -266,17 +266,15 @@
return self.wrap(cls.__dict__[name])
return None
- def unpacktuple(self, w_tuple):
+ def unpacktuple(self, w_tuple, expected_length=None):
import tupleobject
assert isinstance(w_tuple, tupleobject.W_TupleObject)
- return w_tuple.wrappeditems
+ t = w_tuple.wrappeditems
+ if expected_length is not None and expected_length != len(t):
+ raise ValueError, "got a tuple of length %d instead of %d" % (
+ len(t), expected_length)
+ return t
- # special visible multimethods
- delegate = DelegateMultiMethod() # delegators
- unwrap = MultiMethod('unwrap', 1, []) # returns an unwrapped object
- is_true = MultiMethod('nonzero', 1, []) # returns an unwrapped bool
- issubtype = MultiMethod('issubtype', 2, [])
- id = MultiMethod('id', 1, [])
class MM:
"Container for multimethods."
@@ -285,6 +283,16 @@
next = MultiMethod('next', 1, ['next']) # iterator interface
call = MultiMethod('call', 1, ['__call__'], varargs=True, keywords=True)
#getattribute = MultiMethod('getattr', 2, ['__getattribute__']) # XXX hack
+ # special visible multimethods
+ delegate = DelegateMultiMethod() # delegators
+ unwrap = MultiMethod('unwrap', 1, []) # returns an unwrapped object
+ is_true = MultiMethod('nonzero', 1, []) # returns an unwrapped bool
+ issubtype = MultiMethod('issubtype', 2, [])
+ id = MultiMethod('id', 1, [])
+
+ unwrap = MM.unwrap
+ delegate = MM.delegate
+ is_true = MM.is_true
def is_(self, w_one, w_two):
# XXX a bit of hacking to gain more speed
@@ -302,12 +310,13 @@
# add all regular multimethods to StdObjSpace
for _name, _symbol, _arity, _specialnames in ObjSpace.MethodTable:
if not hasattr(StdObjSpace.MM, _name):
- if isinstance(getattr(StdObjSpace, _name, None), MultiMethod):
- mm = getattr(StdObjSpace, _name)
- else:
- mm = MultiMethod(_symbol, _arity, _specialnames)
+## if isinstance(getattr(StdObjSpace, _name, None), MultiMethod):
+## mm = getattr(StdObjSpace, _name)
+## else:
+ mm = MultiMethod(_symbol, _arity, _specialnames)
setattr(StdObjSpace.MM, _name, mm)
-
+ if not hasattr(StdObjSpace, _name):
+ setattr(StdObjSpace, _name, getattr(StdObjSpace.MM, _name))
# import the common base W_ObjectObject as well as
# default implementations of some multimethods for all objects
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/stdtypedef.py Fri Jun 4 21:15:37 2004
@@ -1,7 +1,7 @@
from pypy.interpreter import eval, function, gateway
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.typedef import attrproperty, attrproperty_w
-from pypy.objspace.std.multimethod import MultiMethod
+from pypy.objspace.std.multimethod import MultiMethod, FailedToImplement
__all__ = ['StdTypeDef', 'newmethod', 'gateway',
'GetSetProperty', 'attrproperty', 'attrproperty_w',
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/stringobject.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/stringobject.py Fri Jun 4 21:15:37 2004
@@ -75,7 +75,7 @@
from pypy.interpreter import gateway
from intobject import W_IntObject
from sliceobject import W_SliceObject
-#import slicetype
+import slicetype
from listobject import W_ListObject
from noneobject import W_NoneObject
from tupleobject import W_TupleObject
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/typeobject.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/typeobject.py Fri Jun 4 21:15:37 2004
@@ -1,5 +1,5 @@
from pypy.objspace.std.objspace import *
-
+from pypy.interpreter.typedef import attrproperty_w
class W_TypeObject(W_Object):
from pypy.objspace.std.typetype import type_typedef as typedef
@@ -26,6 +26,11 @@
space.wrap("instance layout conflicts in "
"multiple inheritance"))
w_self.instancetypedef = longest_mro[0]
+ # provide a __dict__ for the instances if there isn't any yet
+ if w_self.lookup('__dict__') is None:
+ w_self.needs_new_dict = True
+ w_self.dict_w['__dict__'] = space.wrap(attrproperty_w('w__dict__'))
+
def getmro(w_self):
# XXX this is something that works not too bad right now
Modified: pypy/branch/src-newobjectmodel/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/objspace/std/typetype.py (original)
+++ pypy/branch/src-newobjectmodel/pypy/objspace/std/typetype.py Fri Jun 4 21:15:37 2004
@@ -17,10 +17,6 @@
dict_w[key] = space.getitem(w_dict, w_key)
# XXX classmethod-ify w_dict['__new__']
w_type = W_TypeObject(space, name, bases_w or [space.w_object], dict_w, None)
- # provide a __dict__ for the instances if there isn't any yet
- if w_type.lookup('__dict__') is None:
- w_type.needs_new_dict = True
- w_type.dict_w['__dict__'] = space.wrap(attrproperty_w('w__dict__'))
return space.w_type.check_user_subclass(w_typetype, w_type)
def descr_get__mro__(space, w_type):
More information about the Pypy-commit
mailing list