Commits

Lukas Diekmann committed ef85a53

erasing bug in _intersection_wrapped. added test and fix

  • Participants
  • Parent commits 3d1995c
  • Branches set-strategies

Comments (0)

Files changed (2)

pypy/objspace/std/setobject.py

             storage = strategy._intersect_unwrapped(w_set, w_other)
         else:
             strategy = self.space.fromcache(ObjectSetStrategy)
-            storage = strategy._intersect_wrapped(w_set, w_other)
+            storage = self._intersect_wrapped(w_set, w_other)
         return storage, strategy
 
     def _intersect_wrapped(self, w_set, w_other):
         result = self.get_empty_dict()
-        items = self.unerase(w_set.sstorage).iterkeys()
-        for key in items:
+        for key in self.unerase(w_set.sstorage):
             w_key = self.wrap(key)
             if w_other.has_key(w_key):
                 result[w_key] = None
-        return self.erase(result)
+
+        strategy = self.space.fromcache(ObjectSetStrategy)
+        return strategy.erase(result)
 
     def _intersect_unwrapped(self, w_set, w_other):
         result = self.get_empty_dict()

pypy/objspace/std/test/test_setobject.py

         assert s1 == set([1,2,3,4])
         assert s2 == set([1,2,3,4])
 
+    def test_intersection_string(self):
+        s = set([1,2,3])
+        o = 'abc'
+        assert s.intersection(o) == set()
+
     def test_difference(self):
         assert set([1,2,3]).difference(set([2,3,4])) == set([1])
         assert set([1,2,3]).difference(frozenset([2,3,4])) == set([1])