Author: Armin Rigo <[email protected]>
Branch: set-strategies
Changeset: r54000:605b7d796555
Date: 2012-03-26 19:35 +0200
http://bitbucket.org/pypy/pypy/changeset/605b7d796555/

Log:    Test and fix.

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1243,9 +1243,10 @@
         try:
             length = space.int_w(space.len(w_other))
         except OperationError, e:
-            if not e.match(space, space.w_TypeError):
-                raise
-            continue
+            if (e.match(space, space.w_TypeError) or
+                e.match(space, space.w_AttributeError)):
+                continue
+            raise
 
         if startlength == -1 or length < startlength:
             startindex = i
diff --git a/pypy/objspace/std/test/test_setobject.py 
b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -900,3 +900,10 @@
         raises(AttributeError, "frozenset().difference_update()")
         raises(AttributeError, "frozenset().symmetric_difference_update()")
         raises(AttributeError, "frozenset().intersection_update()")
+
+    def test_intersection_obj(self):
+        class Obj:
+            def __getitem__(self, i):
+                return [5, 3, 4][i]
+        s = set([10,3,2]).intersection(Obj())
+        assert list(s) == [3]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to