Commits

Armin Rigo committed cf24a62

Fix a set-strategy bug: set-of-ints.update(empty-set) would devolve the
set to set-of-objects...

Comments (0)

Files changed (2)

pypy/objspace/std/setobject.py

             d_other = self.unerase(w_other.sstorage)
             d_set.update(d_other)
             return
-
+        if w_other.length() == 0:
+            return
         w_set.switch_to_object_strategy(self.space)
         w_set.update(w_other)
 

pypy/objspace/std/test/test_setobject.py

         # did not work before because of an optimization that swaps both
         # operands when the first set is larger than the second
         assert type(frozenset([1, 2]) & set([2])) is frozenset
+
+    def test_update_bug_strategy(self):
+        from __pypy__ import strategy
+        s = set([1, 2, 3])
+        assert strategy(s) == "IntegerSetStrategy"
+        s.update(set())
+        assert strategy(s) == "IntegerSetStrategy"