[pypy-commit] pypy default: Fix a set-strategy bug: set-of-ints.update(empty-set) would devolve the

arigo noreply at buildbot.pypy.org
Wed Jul 9 17:20:21 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r72399:cf24a62874df
Date: 2014-07-09 17:19 +0200
http://bitbucket.org/pypy/pypy/changeset/cf24a62874df/

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

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
@@ -1181,7 +1181,8 @@
             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)
 
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
@@ -960,3 +960,10 @@
         # 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"


More information about the pypy-commit mailing list