[pypy-svn] rev 602 - in pypy/trunk/src/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Tue May 27 18:26:34 CEST 2003


Author: arigo
Date: Tue May 27 18:26:33 2003
New Revision: 602

Modified:
   pypy/trunk/src/pypy/objspace/std/floatobject.py
   pypy/trunk/src/pypy/objspace/std/intobject.py
   pypy/trunk/src/pypy/objspace/std/listobject.py
   pypy/trunk/src/pypy/objspace/std/longobject.py
   pypy/trunk/src/pypy/objspace/std/test/test_tupleobject.py
Log:
merging changes with mwh, hold on...

Modified: pypy/trunk/src/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/floatobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/floatobject.py	Tue May 27 18:26:33 2003
@@ -23,7 +23,7 @@
     if w_value.__class__ == W_FloatObject:
         return w_value
     else:
-        return W_FloatObject(w_value.floatval)
+        return W_FloatObject(space, w_value.floatval)
 
 StdObjSpace.float.register(float_float, W_FloatObject)
 
@@ -67,7 +67,7 @@
         z = x + y
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float addition"))
-    return W_FloatObject(z)
+    return W_FloatObject(space, z)
 
 StdObjSpace.add.register(float_float_add, W_FloatObject, W_FloatObject)
 
@@ -78,7 +78,7 @@
         z = x - y
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float substraction"))
-    return W_FloatObject(z)
+    return W_FloatObject(space, z)
 
 StdObjSpace.sub.register(float_float_sub, W_FloatObject, W_FloatObject)
 
@@ -89,7 +89,7 @@
         z = x * y
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float multiplication"))
-    return W_FloatObject(z)
+    return W_FloatObject(space, z)
 
 StdObjSpace.mul.register(float_float_mul, W_FloatObject, W_FloatObject)
 
@@ -101,7 +101,7 @@
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float division"))
 	# no overflow
-    return W_FloatObject(z)
+    return W_FloatObject(space, z)
 
 StdObjSpace.div.register(float_float_div, W_FloatObject, W_FloatObject)
 
@@ -118,7 +118,7 @@
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float division"))
 
-    return W_FloatObject(mod)
+    return W_FloatObject(space, mod)
 
 StdObjSpace.mod.register(float_float_mod, W_FloatObject, W_FloatObject)
 
@@ -149,7 +149,8 @@
     except FloatingPointError:
         raise FailedToImplement(space.w_FloatingPointError, space.wrap("float division"))
 
-    return space.newtuple([W_FloatObject(floordiv),W_FloatObject(mod)])
+    return space.newtuple([W_FloatObject(space, floordiv),
+                           W_FloatObject(space, mod)])
 
 StdObjSpace.divmod.register(float_float_divmod, W_FloatObject, W_FloatObject)
 
@@ -162,12 +163,12 @@
         z = x ** y
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError, space.wrap("float power"))
-    return W_FloatObject(z)
+    return W_FloatObject(space, z)
 
 StdObjSpace.pow.register(float_float_pow, W_FloatObject, W_FloatObject)
 
 def float_neg(space, w_float1):
-    return W_FloatObject(w_float1.floatval)
+    return W_FloatObject(space, w_float1.floatval)
 
 StdObjSpace.neg.register(float_neg, W_FloatObject)
 
@@ -175,12 +176,12 @@
     if w_float.__class__ == W_FloatObject:
         return w_float
     else:
-        return W_FloatObject(w_float.floatval)
+        return W_FloatObject(space, w_float.floatval)
 
 StdObjSpace.pos.register(float_pos, W_FloatObject)
 
 def float_abs(space, w_float):
-    return W_FloatObject(fabs(w_float.floatval))
+    return W_FloatObject(space, fabs(w_float.floatval))
 
 StdObjSpace.abs.register(float_abs, W_FloatObject)
 
@@ -195,7 +196,7 @@
     if w_float.__class__ == W_FloatObject:
         return w_float
     else:
-        return W_FloatObject(w_float.floatval)
+        return W_FloatObject(space, w_float.floatval)
 
 StdObjSpace.coerce.register(float_coerce, W_FloatObject)
 """

Modified: pypy/trunk/src/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/intobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/intobject.py	Tue May 27 18:26:33 2003
@@ -34,7 +34,7 @@
 
 
 def bool_to_int(space, w_bool):
-    return W_IntObject(int(w_bool.boolval))
+    return W_IntObject(space, int(w_bool.boolval))
 W_BoolObject.delegate_once[W_IntObject] = bool_to_int
 
 
@@ -74,7 +74,7 @@
 ##        ret = 1
 ##    else:
 ##        ret = 0
-##    return W_IntObject(ret)
+##    return W_IntObject(space, ret)
 ##
 ##StdObjSpace.cmp.register(int_int_cmp, W_IntObject, W_IntObject)
 
@@ -122,7 +122,7 @@
     x = w_int1.intval
     if x == -1:
         x = -2
-    return W_IntObject(x)
+    return W_IntObject(space, x)
 
 def int_hash_liberal(space, w_int1):
     # Armin: unlike CPython we have no need to special-case the value -1
@@ -149,7 +149,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer addition"))
-    return W_IntObject(z)
+    return W_IntObject(space, z)
 
 StdObjSpace.add.register(int_int_add, W_IntObject, W_IntObject)
 
@@ -161,7 +161,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer substraction"))
-    return W_IntObject(z)
+    return W_IntObject(space, z)
 
 StdObjSpace.sub.register(int_int_sub, W_IntObject, W_IntObject)
 
@@ -173,7 +173,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer multiplication"))
-    return W_IntObject(z)
+    return W_IntObject(space, z)
 
 StdObjSpace.mul.register(int_int_mul, W_IntObject, W_IntObject)
 
@@ -188,7 +188,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer division"))
-    return W_IntObject(z)
+    return W_IntObject(space, z)
 
 StdObjSpace.floordiv.register(int_int_floordiv, W_IntObject, W_IntObject)
 
@@ -210,7 +210,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer modulo"))
-    return W_IntObject(z)
+    return W_IntObject(space, z)
 
 StdObjSpace.mod.register(int_int_mod, W_IntObject, W_IntObject)
 
@@ -280,7 +280,7 @@
     y = w_int2.intval
     z = w_int3.intval
     ret = _impl_int_int_pow(space, x, y, z)
-    return W_IntObject(ret)
+    return W_IntObject(space, ret)
 
 StdObjSpace.pow.register(int_int_int_pow, W_IntObject, W_IntObject, W_IntObject)
 
@@ -288,7 +288,7 @@
     x = w_int1.intval
     y = w_int2.intval
     ret = _impl_int_int_pow(space, x, y)
-    return W_IntObject(ret)
+    return W_IntObject(space, ret)
 
 StdObjSpace.pow.register(int_int_none_pow, W_IntObject, W_IntObject, W_NoneObject)
 
@@ -299,7 +299,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer negation"))
-    return W_IntObject(x)
+    return W_IntObject(space, x)
 
 StdObjSpace.neg.register(int_neg, W_IntObject)
 
@@ -311,7 +311,7 @@
     if w_int1.__class__ is W_IntObject:
         return w_int1
     a = w_int1.intval
-    return W_IntObject(a)
+    return W_IntObject(space, a)
 
 StdObjSpace.pos.register(int_pos, W_IntObject)
 
@@ -331,7 +331,7 @@
 def int_invert(space, w_int1):
     x = w_int1.intval
     a = ~x
-    return W_IntObject(a)
+    return W_IntObject(space, a)
 
 StdObjSpace.invert.register(int_invert, W_IntObject)
 
@@ -360,7 +360,7 @@
     except OverflowError:
         raise FailedToImplement(space.w_OverflowError,
                                 space.wrap("integer left shift"))
-    return W_IntObject(c);
+    return W_IntObject(space, c)
 
 StdObjSpace.lshift.register(int_int_lshift, W_IntObject, W_IntObject)
 
@@ -381,7 +381,7 @@
         ## please look into pyport.h, how >> should be implemented!
         ## a = Py_ARITHMETIC_RIGHT_SHIFT(long, a, b);
         a = a >> b
-    return W_IntObject(a)
+    return W_IntObject(space, a)
 
 StdObjSpace.rshift.register(int_int_rshift, W_IntObject, W_IntObject)
 
@@ -389,7 +389,7 @@
     a = w_int1.intval
     b = w_int2.intval
     res = a & b
-    return W_IntObject(res)
+    return W_IntObject(space, res)
 
 StdObjSpace.and_.register(int_int_and, W_IntObject, W_IntObject)
 
@@ -397,7 +397,7 @@
     a = w_int1.intval
     b = w_int2.intval
     res = a ^ b
-    return W_IntObject(res)
+    return W_IntObject(space, res)
 
 StdObjSpace.xor.register(int_int_xor, W_IntObject, W_IntObject)
 
@@ -405,7 +405,7 @@
     a = w_int1.intval
     b = w_int2.intval
     res = a | b
-    return W_IntObject(res)
+    return W_IntObject(space, res)
 
 StdObjSpace.or_.register(int_int_or, W_IntObject, W_IntObject)
 
@@ -456,7 +456,7 @@
         ret = "0%lo" % x
     return space.wrap(ret)
 
-#?StdObjSpace.oct.register(int_oct, W_IntObject)
+StdObjSpace.oct.register(int_oct, W_IntObject)
 
 def int_hex(space, w_int1):
     x = w_int1.intval
@@ -473,4 +473,4 @@
         ret = "0x%lx" % x
     return space.wrap(ret)
 
-#?StdObjSpace.hex.register(int_hex, W_IntObject)
+StdObjSpace.hex.register(int_hex, W_IntObject)

Modified: pypy/trunk/src/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/listobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/listobject.py	Tue May 27 18:26:33 2003
@@ -34,7 +34,7 @@
 
 def list_len(space, w_list):
     result = len(w_list.wrappeditems)
-    return W_IntObject(result)
+    return W_IntObject(space, result)
 
 StdObjSpace.len.register(list_len, W_ListObject)
 
@@ -61,27 +61,27 @@
     for i in range(slicelength):
         subitems[i] = items[start]
         start += step
-    return W_ListObject(subitems)
+    return W_ListObject(space, subitems)
 
 StdObjSpace.getitem.register(getitem_list_slice, W_ListObject, W_SliceObject)
 
 def list_iter(space, w_list):
     import iterobject
-    return iterobject.W_SeqIterObject(w_list)
+    return iterobject.W_SeqIterObject(space, w_list)
 
 StdObjSpace.iter.register(list_iter, W_ListObject)
 
 def list_add(space, w_list1, w_list2):
     items1 = w_list1.wrappeditems
     items2 = w_list2.wrappeditems
-    return W_ListObject(items1 + items2)
+    return W_ListObject(space, items1 + items2)
 
 StdObjSpace.add.register(list_add, W_ListObject, W_ListObject)
 
 def list_int_mul(space, w_list, w_int):
     items = w_list.wrappeditems
     times = w_int.intval
-    return W_ListObject(items * times)
+    return W_ListObject(space, items * times)
 
 StdObjSpace.mul.register(list_int_mul, W_ListObject, W_IntObject)
 
@@ -103,7 +103,7 @@
 def getattr_list(space, w_list, w_attr):
     if space.is_true(space.eq(w_attr, space.wrap('append'))):
         w_builtinfn = make_builtin_func(space, W_ListObject.append)
-        return W_InstMethObject(w_list, w_builtinfn)
+        return W_InstMethObject(space, w_list, w_builtinfn)
     raise FailedToImplement(space.w_AttributeError)
 
 StdObjSpace.getattr.register(getattr_list, W_ListObject, W_ANY)

Modified: pypy/trunk/src/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/longobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/longobject.py	Tue May 27 18:26:33 2003
@@ -22,7 +22,7 @@
         z = x + y
     except OverflowError:
         raise OperationError(OverflowError, "long addition")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_sub(space, w_long1, w_long2):
     x = w_long1.longval
@@ -31,7 +31,7 @@
         z = x - y
     except Error,e:
         raise OperationError(Error, e)
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_mul(space, w_long1, w_long2):
     x = w_long1.longval
@@ -40,7 +40,7 @@
         z = x * y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_floordiv(space, w_long1, w_long2):
     x = w_long1.longval
@@ -50,7 +50,7 @@
     except ZeroDivisionError:
 		raise   # we have to implement the exception or it will be ignored
 	# no overflow
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_truediv(space, w_long1, w_long2):
     x = w_long1.longval
@@ -60,7 +60,7 @@
     except ZeroDivisionError:
 		raise   # we have to implement the exception or it will be ignored
 	# no overflow
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 if 1L / 2L == 1L // 2L:
 	long_long_div = long_long_floordiv
@@ -75,7 +75,7 @@
     except ZeroDivisionError:
 		raise   # we have to implement the exception or it will be ignored
 	# no overflow
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_divmod(space, w_long1, w_long2):
     x = w_long1.longval
@@ -86,7 +86,8 @@
     except ZeroDivisionError:
 		raise   # we have to implement the exception or it will be ignored
 	# no overflow
-    return W_TupleObject([z, m])
+    return W_TupleObject(space, [W_LongObject(space, z),
+                                 W_LongObject(space, m)])
 
 def long_long_pow(space, w_long1,w_long2):
     x = w_long1.longval
@@ -95,7 +96,7 @@
         z = x ** y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_long_pow(space, w_long1,w_long2,w_long3):
     x = w_long1.longval
@@ -105,7 +106,7 @@
         z = (x ** y) % z
     except Error,e:
         raise OperationError(Error(e), "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_lshift(space, w_long1,w_long2):
     x = w_long1.longval
@@ -114,7 +115,7 @@
         z = x << y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_rshift(space, w_long1,w_long2):
     x = w_long1.longval
@@ -123,7 +124,7 @@
         z = x >> y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_and(space, w_long1,w_long2):
     x = w_long1.longval
@@ -132,7 +133,7 @@
         z = x & y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_xor(space, w_long1,w_long2):
     x = w_long1.longval
@@ -141,7 +142,7 @@
         z = x ^ y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 def long_long_or(space, w_long1,w_long2):
     x = w_long1.longval
@@ -150,7 +151,7 @@
         z = x | y
     except OverflowError:
         raise OperationError(OverflowError, "long multiplication")
-    return W_LongObject(z)
+    return W_LongObject(space, z)
 
 
 

Modified: pypy/trunk/src/pypy/objspace/std/test/test_tupleobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_tupleobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_tupleobject.py	Tue May 27 18:26:33 2003
@@ -16,25 +16,25 @@
 
     def test_is_true(self):
         w = self.space.wrap
-        w_tuple = tobj.W_TupleObject([])
+        w_tuple = tobj.W_TupleObject(self.space, [])
         self.assertEqual(self.space.is_true(w_tuple), False)
-        w_tuple = tobj.W_TupleObject([w(5)])
+        w_tuple = tobj.W_TupleObject(self.space, [w(5)])
         self.assertEqual(self.space.is_true(w_tuple), True)
-        w_tuple = tobj.W_TupleObject([w(5), w(3)])
+        w_tuple = tobj.W_TupleObject(self.space, [w(5), w(3)])
         self.assertEqual(self.space.is_true(w_tuple), True)
 
     def test_len(self):
         w = self.space.wrap
-        w_tuple = tobj.W_TupleObject([])
+        w_tuple = tobj.W_TupleObject(self.space, [])
         self.assertEqual_w(self.space.len(w_tuple), w(0))
-        w_tuple = tobj.W_TupleObject([w(5)])
+        w_tuple = tobj.W_TupleObject(self.space, [w(5)])
         self.assertEqual_w(self.space.len(w_tuple), w(1))
-        w_tuple = tobj.W_TupleObject([w(5), w(3), w(99)]*111)
+        w_tuple = tobj.W_TupleObject(self.space, [w(5), w(3), w(99)]*111)
         self.assertEqual_w(self.space.len(w_tuple), w(333))
 
     def test_getitem(self):
         w = self.space.wrap
-        w_tuple = tobj.W_TupleObject([w(5), w(3)])
+        w_tuple = tobj.W_TupleObject(self.space, [w(5), w(3)])
         self.assertEqual_w(self.space.getitem(w_tuple, w(0)), w(5))
         self.assertEqual_w(self.space.getitem(w_tuple, w(1)), w(3))
         self.assertEqual_w(self.space.getitem(w_tuple, w(-2)), w(5))
@@ -48,7 +48,7 @@
 
     def test_iter(self):
         w = self.space.wrap
-        w_tuple = tobj.W_TupleObject([w(5), w(3), w(99)])
+        w_tuple = tobj.W_TupleObject(self.space, [w(5), w(3), w(99)])
         w_iter = self.space.iter(w_tuple)
         self.assertEqual_w(self.space.next(w_iter), w(5))
         self.assertEqual_w(self.space.next(w_iter), w(3))
@@ -58,15 +58,15 @@
 
     def test_add(self):
         w = self.space.wrap
-        w_tuple0 = tobj.W_TupleObject([])
-        w_tuple1 = tobj.W_TupleObject([w(5), w(3), w(99)])
-        w_tuple2 = tobj.W_TupleObject([w(-7)] * 111)
+        w_tuple0 = tobj.W_TupleObject(self.space, [])
+        w_tuple1 = tobj.W_TupleObject(self.space, [w(5), w(3), w(99)])
+        w_tuple2 = tobj.W_TupleObject(self.space, [w(-7)] * 111)
         self.assertEqual_w(self.space.add(w_tuple1, w_tuple1),
-                           tobj.W_TupleObject([w(5), w(3), w(99),
-                                               w(5), w(3), w(99)]))
+                           tobj.W_TupleObject(self.space, [w(5), w(3), w(99),
+                                                           w(5), w(3), w(99)]))
         self.assertEqual_w(self.space.add(w_tuple1, w_tuple2),
-                           tobj.W_TupleObject([w(5), w(3), w(99)] +
-                                              [w(-7)] * 111))
+                           tobj.W_TupleObject(self.space, [w(5), w(3), w(99)] +
+                                                          [w(-7)] * 111))
         self.assertEqual_w(self.space.add(w_tuple1, w_tuple0), w_tuple1)
         self.assertEqual_w(self.space.add(w_tuple0, w_tuple2), w_tuple2)
 
@@ -75,8 +75,8 @@
         w = self.space.wrap
         arg = w(2)
         n = 3
-        w_tup = tobj.W_TupleObject([arg])
-        w_tup3 = tobj.W_TupleObject([arg]*n)
+        w_tup = tobj.W_TupleObject(self.space, [arg])
+        w_tup3 = tobj.W_TupleObject(self.space, [arg]*n)
         w_res = self.space.mul(w_tup, w(n))
         self.assertEqual_w(w_tup3, w_res)
 
@@ -85,7 +85,7 @@
 
         def test1(testtuple, start, stop, step, expected):
             w_slice  = self.space.newslice(w(start), w(stop), w(step))
-            w_tuple = tobj.W_TupleObject([w(i) for i in testtuple])
+            w_tuple = tobj.W_TupleObject(self.space, [w(i) for i in testtuple])
             w_result = self.space.getitem(w_tuple, w_slice)
             self.assertEqual(self.space.unwrap(w_result), expected)
         


More information about the Pypy-commit mailing list