[pypy-svn] r59157 - in pypy/trunk/pypy/objspace/std: . test
iko at codespeak.net
iko at codespeak.net
Thu Oct 16 22:05:42 CEST 2008
Author: iko
Date: Thu Oct 16 22:05:42 2008
New Revision: 59157
Modified:
pypy/trunk/pypy/objspace/std/test/test_tupleobject.py
pypy/trunk/pypy/objspace/std/tupleobject.py
Log:
fix tuple * 1 is tuple checked by CPython tests
Modified: pypy/trunk/pypy/objspace/std/test/test_tupleobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_tupleobject.py (original)
+++ pypy/trunk/pypy/objspace/std/test/test_tupleobject.py Thu Oct 16 22:05:42 2008
@@ -83,6 +83,9 @@
# commute
w_res = self.space.mul(w(n), w_tup)
assert self.space.eq_w(w_tup3, w_res)
+ # check tuple*1 is identity (optimisation tested by CPython tests)
+ w_res = self.space.mul(w_tup, w(1))
+ assert w_res is w_tup
def test_getslice(self):
w = self.space.wrap
@@ -277,6 +280,8 @@
assert () * 10 == ()
assert (5,) * 3 == (5,5,5)
assert (5,2) * 2 == (5,2,5,2)
+ t = (1,2,3)
+ assert (t * 1) is t
def test_getslice(self):
assert (5,2,3)[1:2] == (2,)
Modified: pypy/trunk/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/tupleobject.py (original)
+++ pypy/trunk/pypy/objspace/std/tupleobject.py Thu Oct 16 22:05:42 2008
@@ -79,7 +79,9 @@
except OperationError, e:
if e.match(space, space.w_TypeError):
raise FailedToImplement
- raise
+ raise
+ if times == 1:
+ return w_tuple
items = w_tuple.wrappeditems
return W_TupleObject(items * times)
More information about the Pypy-commit
mailing list