[pypy-commit] pypy space-iterator-improvements: A questionable test, but matches cpython behavior. The change itself makes
fijal
noreply at buildbot.pypy.org
Thu Sep 8 09:50:54 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: space-iterator-improvements
Changeset: r47159:b4bff794fea0
Date: 2011-09-08 09:50 +0200
http://bitbucket.org/pypy/pypy/changeset/b4bff794fea0/
Log: A questionable test, but matches cpython behavior. The change itself
makes sense however.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -759,7 +759,10 @@
if expected_length == -1:
try:
lgt_estimate = self.len_w(w_iterable)
- except OperationError:
+ except OperationError, o:
+ if (not o.match(self, self.w_AttributeError) and
+ not o.match(self, self.w_TypeError)):
+ raise
items = []
else:
try:
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -71,6 +71,23 @@
assert err.value.match(space, space.w_ValueError)
err = raises(OperationError, space.unpackiterable, w_l, 5)
assert err.value.match(space, space.w_ValueError)
+ w_a = space.appexec((), """():
+ class A(object):
+ def __iter__(self):
+ return self
+ def next(self):
+ raise StopIteration
+ def __len__(self):
+ 1/0
+ return A()
+ """)
+ try:
+ space.unpackiterable(w_a)
+ except OperationError, o:
+ if not o.match(space, space.w_ZeroDivisionError):
+ raise Exception("DID NOT RAISE")
+ else:
+ raise Exception("DID NOT RAISE")
def test_fixedview(self):
space = self.space
More information about the pypy-commit
mailing list