Author: Benjamin Peterson <[email protected]>
Branch: py3k
Changeset: r53343:ffa255eda33c
Date: 2012-03-12 13:48 -0700
http://bitbucket.org/pypy/pypy/changeset/ffa255eda33c/
Log: (db42) fix iter and int tests
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -368,7 +368,7 @@
raise RuntimeError("deque mutated during iteration")
self._gen = itergen(deq.state, giveup)
- def next(self):
+ def __next__(self):
res = self._gen.next()
self.counter -= 1
return res
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -41,7 +41,10 @@
else:
w_obj = space.trunc(w_obj)
w_obj = space.int(w_obj)
- return w_obj
+ if space.is_w(w_longtype, space.w_int):
+ return w_obj
+ bigint = space.bigint_w(w_obj)
+ return newbigint(space, w_longtype, bigint)
else:
base = space.int_w(w_base)
diff --git a/pypy/objspace/std/test/test_iterobject.py
b/pypy/objspace/std/test/test_iterobject.py
--- a/pypy/objspace/std/test/test_iterobject.py
+++ b/pypy/objspace/std/test/test_iterobject.py
@@ -39,7 +39,7 @@
class AppTestW_IterObjectApp:
def test_user_iter(self):
class C(object):
- def next(self):
+ def __next__(self):
raise StopIteration
def __iter__(self):
return self
@@ -49,7 +49,7 @@
class C(object):
def __getitem__(self, i):
return range(2)[i]
- assert list(C()) == range(2)
+ assert list(C()) == list(range(2))
def test_iter_fail_noseq(self):
class C(object):
@@ -82,13 +82,16 @@
raises(TypeError, len, it)
def test_no_len_on_UserList_iter(self):
- from UserList import UserList
+ class UserList(object):
+ def __init__(self, i):
+ self.i = i
+ def __getitem__(self, i):
+ return range(self.i)[i]
iterable = UserList([1,2,3,4])
raises(TypeError, len, iter(iterable))
def test_no_len_on_UserList_reversed(self):
- from UserList import UserList
- iterable = UserList([1,2,3,4])
+ iterable = [1,2,3,4]
raises(TypeError, len, reversed(iterable))
def test_no_len_on_set_iter(self):
@@ -96,5 +99,5 @@
raises(TypeError, len, iter(iterable))
def test_no_len_on_xrange(self):
- iterable = xrange(10)
+ iterable = range(10)
raises(TypeError, len, iter(iterable))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit