[pypy-commit] pypy set-strategies: added test and fix for inplace sub

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:49:24 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49143:6b7510a9e193
Date: 2011-05-02 13:05 +0200
http://bitbucket.org/pypy/pypy/changeset/6b7510a9e193/

Log:	added test and fix for inplace sub

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
@@ -558,8 +558,7 @@
                     pass
 
 def inplace_sub__Set_Set(space, w_left, w_other):
-    ld, rd = w_left.setdata, w_other.setdata
-    _difference_dict_update(space, ld, rd)
+    w_left.difference_update(w_other)
     return w_left
 
 inplace_sub__Set_Frozenset = inplace_sub__Set_Set
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
@@ -79,6 +79,12 @@
         a - b == [1,5]
         a.__sub__(b) == [1,5]
 
+        #inplace sub
+        a = set([1,2,3,4])
+        b = set([1,4])
+        a -= b
+        assert a == set([2,3])
+
     def test_discard_remove(self):
         a = set([1,2,3,4,5])
         a.remove(1)


More information about the pypy-commit mailing list