Commits

Carl Friedrich Bolz committed ae47a8c

changing space.is_true(space.is_ to space.is_w and space.is_true(space.eq to
space.eq_w a bit everywhere. Also remove commented out code.

  • Participants
  • Parent commits 4e0bd06

Comments (0)

Files changed (11)

File pypy/objspace/std/default.py

 def init__ANY(space, w_obj, __args__):
     pass
 
-
-# __nonzero__ falls back to __len__
-
-##def is_true__ANY(space, w_obj):
-##    w_descr = space.lookup(w_obj, '__len__')
-##    if w_descr is None:
-##        return True
-##    else:
-##        w_len = space.get_and_call_function(w_descr, w_obj)
-##        return space.is_true(w_len)
-
-### in-place operators fall back to their non-in-place counterpart
-
-##for _name, _symbol, _arity, _specialnames in ObjSpace.MethodTable:
-##    if _name.startswith('inplace_'):
-##        def default_inplace(space, w_1, w_2, baseop=_name[8:]):
-##            op = getattr(space, baseop)
-##            return op(w_1, w_2)
-##        getattr(StdObjSpace.MM, _name).register(default_inplace,
-##                                                W_Object, W_ANY)
-
-# '__get__(descr, inst, cls)' returns 'descr' by default
-
-#def get__Object_ANY_ANY(space, w_descr, w_inst, w_cls):
-#    return w_descr
-
-#def is_data_descr__Object(space, w_descr):
-#    return 0
-
-# give objects some default attributes and a default way to complain
-# about missing attributes
-
-##def getattribute__Object_ANY(space, w_obj, w_attr):
-##    # XXX build a nicer error message along these lines:
-##    #w_type = space.type(w_obj)
-##    #w_typename = space.getattr(w_type, space.wrap('__name__'))
-##    #...
-
-##    w_type = space.type(w_obj)
-##    if space.is_true(space.eq(w_attr, space.wrap('__class__'))):
-##        return w_type
-
-##    # 1) look for descriptor
-##    # 2) if data descriptor, call it
-##    # 3) check __dict__
-##    # 4) if present, return that
-##    # 5) if descriptor found in 2), call that
-##    # 6) raise AttrbuteError
-
-##    w_descr = None
-
-##    from typeobject import W_TypeObject
-##    if isinstance(w_type, W_TypeObject):  # XXX must always be true at some point
-##        try:
-##            w_descr = w_type.lookup(w_attr)
-##        except KeyError:
-##            pass
-##        else:
-##            if space.is_data_descr(w_descr):
-##                return space.get(w_descr, w_obj, w_type) # XXX 3rd arg is wrong
-    
-##    try:
-##        w_dict = space.getdict(w_obj)
-##    except OperationError, e:
-##        if not e.match(space, space.w_TypeError): # 'unsupported type for getdict'
-##            raise
-##    else:
-##        if space.is_true(space.eq(w_attr, space.wrap('__dict__'))):
-##            return w_dict
-##        try:
-##            w_value = space.getitem(w_dict, w_attr)
-##        except OperationError, e:
-##            if not e.match(space, space.w_KeyError):
-##                raise
-##        else:
-##            return w_value  # got a value from 'obj.__dict__[attr]'
-
-##    if w_descr is not None:
-##        return space.get(w_descr, w_obj, w_type)
-        
-##    raise OperationError(space.w_AttributeError, w_attr)
-
-
-# set attributes, complaining about read-only ones --
-# a more declarative way to define attributes would be welcome
-
-##def setattr__Object_ANY_ANY(space, w_obj, w_attr, w_value):
-
-##    # 1) look for descriptor
-##    # 2) if data descriptor, call it
-##    # 3) try to set item in __dict__
-
-##    w_type = space.type(w_obj)
-##    if space.is_true(space.eq(w_attr, space.wrap('__class__'))):
-##        raise OperationError(space.w_AttributeError,
-##                             space.wrap("read-only attribute"))
-##    if space.is_true(space.eq(w_attr, space.wrap('__dict__'))):
-##        raise OperationError(space.w_AttributeError,
-##                             space.wrap("read-only attribute"))
-
-##    from typeobject import W_TypeObject
-##    if isinstance(w_type, W_TypeObject):
-##        try:
-##            w_descr = w_type.lookup(w_attr)
-##        except KeyError:
-##            pass
-##        else:
-##            if space.is_data_descr(w_descr):
-##                return space.set(w_descr, w_obj, w_value)
-    
-##    try:
-##        w_dict = space.getdict(w_obj)
-##    except OperationError, e:
-##        if not e.match(space, space.w_TypeError): # "unsupported type for getdict"
-##            raise
-##        raise OperationError(space.w_AttributeError, w_attr)
-##    else:
-##        space.setitem(w_dict, w_attr, w_value)
-            
-
-##def delattr__Object_ANY(space, w_obj, w_attr):
-##    w_type = space.type(w_obj)
-##    if space.is_true(space.eq(w_attr, space.wrap('__class__'))):
-##        raise OperationError(space.w_AttributeError,
-##                             space.wrap("read-only attribute"))
-##    if space.is_true(space.eq(w_attr, space.wrap('__dict__'))):
-##        raise OperationError(space.w_AttributeError,
-##                             space.wrap("read-only attribute"))
-
-##    from typeobject import W_TypeObject
-##    if isinstance(w_type, W_TypeObject):
-##        try:
-##            w_descr = w_type.lookup(w_attr)
-##        except KeyError:
-##            pass
-##        else:
-##            #space.type(w_descr).lookup(space.wrap('__delete__'))
-##            if space.is_data_descr(w_descr):
-##                return space.delete(w_descr, w_obj)
-    
-##    try:
-##        w_dict = space.getdict(w_obj)
-##    except OperationError, e:
-##        if not e.match(space, space.w_TypeError): # "unsupported type for getdict"
-##            raise
-##        raise OperationError(space.w_AttributeError, w_attr)
-##    else:
-##        try:
-##            space.delitem(w_dict, w_attr)
-##        except OperationError, e:
-##            if not e.match(space, space.w_KeyError):
-##                raise
-##            raise OperationError(space.w_AttributeError, w_attr)
-
-# static types
-
-##def type__Object(space, w_obj):
-##    if w_obj.statictype is None:
-##        # XXX remove me, temporary
-##        return space.wrap(space.unwrap(w_obj).__class__)
-##    else:
-##        w_type = space.get_typeinstance(w_obj.statictype)
-##        return w_type
-
-# repr(), str(), hash()
-
-##def repr__Object(space, w_obj):
-##    return space.wrap('<%s object at %s>'%(
-##        space.type(w_obj).typename, space.unwrap(space.id(w_obj))))
-
-##def str__Object(space, w_obj):
-##    return space.repr(w_obj)
-
-##def hash__ANY(space, w_obj):
-##    return space.id(w_obj)
-
-
-# The following operations are fall-backs if we really cannot find
-# anything else even with delegation.
-# 'eq' falls back to 'is'
-
-##def eq__ANY_ANY(space, w_a, w_b):
-##    return space.is_(w_a, w_b)
-
-# 'contains' falls back to iteration.
-
-##def contains__ANY_ANY(space, w_iterable, w_lookfor):
-##    w_iter = space.iter(w_iterable)
-##    while 1:
-##        try:
-##            w_next = space.next(w_iter)
-##        except OperationError, e:
-##            if not e.match(space, space.w_StopIteration):
-##                raise
-##            return space.w_False
-##        if space.is_true(space.eq(w_next, w_lookfor)):
-##            return space.w_True
-
-# ugh
-
 def typed_unwrap_error_msg(space, expected, w_obj):
     w = space.wrap
     type_name = space.str_w(space.getattr(space.type(w_obj),w("__name__")))

File pypy/objspace/std/dictobject.py

     return W_DictIter_Keys(space, w_dict)
 
 def eq__Dict_Dict(space, w_left, w_right):
-    if space.is_true(space.is_(w_left, w_right)):
+    if space.is_w(w_left, w_right):
         return space.w_True
 
     if len(w_left.content) != len(w_right.content):

File pypy/objspace/std/floattype.py

                                  space.wrap(e.msg))
     else:
         w_obj = space.float(w_value)
-        if space.is_true(space.is_(w_floattype, space.w_float)):
+        if space.is_w(w_floattype, space.w_float):
             return w_obj  # 'float(x)' should return
                           # whatever x.__float__() returned
         value = space.float_w(w_obj)

File pypy/objspace/std/inttype.py

             # otherwise, use the __int__() method
             w_obj = space.int(w_value)
             # 'int(x)' should return whatever x.__int__() returned
-            if space.is_true(space.is_(w_inttype, space.w_int)):
+            if space.is_w(w_inttype, space.w_int):
                 return w_obj
             # int_w is effectively what we want in this case,
             # we cannot construct a subclass of int instance with an
             w_longval = retry_to_w_long(space, e.parser, base)                        
 
     if w_longval is not None:
-        if not space.is_true(space.is_(w_inttype, space.w_int)):
+        if not space.is_w(w_inttype, space.w_int):
             raise OperationError(space.w_OverflowError,
                                  space.wrap(
                 "long int too large to convert to int"))          

File pypy/objspace/std/longtype.py

             # otherwise, use the __long__() method
             w_obj = space.long(w_value)
             # 'long(x)' should return whatever x.__long__() returned
-            if space.is_true(space.is_(w_longtype, space.w_long)):
+            if space.is_w(w_longtype, space.w_long):
                 return w_obj
             if space.is_true(space.isinstance(w_obj, space.w_long)):
                 assert isinstance(w_obj, W_LongObject)  # XXX this could fail!

File pypy/objspace/std/sliceobject.py

 
     def indices3(w_slice, length):
         space = w_slice.space
-        if space.is_true(space.is_(w_slice.w_step, space.w_None)):
+        if space.is_w(w_slice.w_step, space.w_None):
             step = 1
         else:
             step = _Eval_SliceIndex(space, w_slice.w_step)
             if step == 0:
                 raise OperationError(space.w_ValueError,
                                      space.wrap("slice step cannot be zero"))
-        if space.is_true(space.is_(w_slice.w_start, space.w_None)):
+        if space.is_w(w_slice.w_start, space.w_None):
             if step < 0:
                 start = length - 1
             else:
                     start = length - 1
                 else:
                     start = length
-        if space.is_true(space.is_(w_slice.w_stop, space.w_None)):
+        if space.is_w(w_slice.w_stop, space.w_None):
             if step < 0:
                 stop = -1
             else:

File pypy/objspace/std/stringobject.py

         #  the keys any more!)
     return W_IntObject(space, x)
 
-
-##EQ = 1
-##LE = 2
-##GE = 3
-##GT = 4
-##LT = 5
-##NE = 6
-
-
-##def string_richcompare(space, w_str1, w_str2, op):
-##    str1 = w_str1._value
-##    str2 = w_str2._value
-
-##    if space.is_true(space.is_(w_str1, w_str2)):
-##        if op == EQ or op == LE or op == GE:
-##            return space.w_True
-##        elif op == GT or op == LT or op == NE:
-##            return space.w_False
-##    if 0:
-##        pass
-##    else:
-##        if op == EQ:
-##            if len(str1) == len(str2):
-##                for i in range(len(str1)):
-##                    if ord(str1[i]) != ord(str2[i]):
-##                        return space.w_False
-##                return space.w_True
-##            else:
-##                return space.w_False
-##        else:
-##            if len(str1) > len(str2):
-##                min_len = len(str2)
-##            else:
-##                min_len = len(str1)
-
-##            c = 0
-##            idx = 0
-##            if (min_len > 0):
-##                while (c == 0) and (idx < min_len):
-##                    c = ord(str1[idx]) - ord(str2[idx])
-##                    idx = idx + 1
-##            else:
-##                c = 0
-
-##        if (c == 0):
-##            if len(str1) < len(str2):
-##                c = -1
-##            elif len(str1) > len(str2):
-##                c = 1
-##            else:
-##                c = 0
-
-##        if op == LT:
-##            return space.newbool(c < 0)
-##        elif op == LE:
-##            return space.newbool(c <= 0)
-##        elif op == NE:
-##            return space.newbool(c != 0)
-##        elif op == GT:
-##            return space.newbool(c > 0)
-##        elif op == GE:
-##            return space.newbool(c >= 0)
-##        else:
-##            return NotImplemented
-
 def lt__String_String(space, w_str1, w_str2):
     s1 = w_str1._value
     s2 = w_str2._value

File pypy/objspace/std/stringtype.py

 def descr__new__(space, w_stringtype, w_object=''):
     from pypy.objspace.std.stringobject import W_StringObject
     w_obj = space.str(w_object)
-    if space.is_true(space.is_(w_stringtype, space.w_str)):
+    if space.is_w(w_stringtype, space.w_str):
         return w_obj  # XXX might be reworked when space.str() typechecks
     value = space.str_w(w_obj)
     w_obj = space.allocate_instance(W_StringObject, w_stringtype)

File pypy/objspace/std/tupleobject.py

     for i in range(len(items1)):
         item1 = items1[i]
         item2 = items2[i]
-        if not space.is_true(space.eq(item1, item2)):
+        if not space.eq_w(item1, item2):
             return space.w_False
     return space.w_True
 
     ncmp = _min(len(items1), len(items2))
     # Search for the first index where items are different
     for p in range(ncmp):
-        if not space.is_true(space.eq(items1[p], items2[p])):
+        if not space.eq_w(items1[p], items2[p]):
             return space.lt(items1[p], items2[p])
     # No more items to compare -- compare sizes
     return space.newbool(len(items1) < len(items2))
     ncmp = _min(len(items1), len(items2))
     # Search for the first index where items are different
     for p in range(ncmp):
-        if not space.is_true(space.eq(items1[p], items2[p])):
+        if not space.eq_w(items1[p], items2[p]):
             return space.gt(items1[p], items2[p])
     # No more items to compare -- compare sizes
     return space.newbool(len(items1) > len(items2))

File pypy/objspace/std/typeobject.py

                 w_self.hasdict = True
                
             w_type = space.type(w_self)
-            if not space.is_true(space.is_(w_type, space.w_type)):
+            if not space.is_w(w_type, space.w_type):
                 w_self.mro_w = []
                 mro_func = w_type.lookup('mro')
                 mro_func_args = Arguments(space, [w_self])
 
 def call__Type(space, w_type, __args__):
     # special case for type(x)
-    if space.is_true(space.is_(w_type, space.w_type)):
+    if space.is_w(w_type, space.w_type):
         try:
             w_obj, = __args__.fixedunpack(1)
         except ValueError:

File pypy/objspace/std/unicodeobject.py

     if len(list) == 0:
         return W_UnicodeObject(space, [])
     if (len(list) == 1 and
-        space.is_true(space.is_(space.type(list[0]), space.w_unicode))):
+        space.is_w(space.type(list[0]), space.w_unicode)):
         return list[0]
     
     values_list = [None] * len(list)