[pypy-commit] pypy set-strategies: difference always expects w_other to be a set

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:51:31 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49216:2bec064b8288
Date: 2011-10-11 14:27 +0200
http://bitbucket.org/pypy/pypy/changeset/2bec064b8288/

Log:	difference always expects w_other to be a set

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
@@ -244,10 +244,6 @@
         return False
 
     def difference(self, w_set, w_other):
-        # XXX what is w_other here? a set or any wrapped object?
-        # if a set, the following line is unnecessary (sets contain only
-        # hashable objects).
-        self.check_for_unhashable_objects(w_other)
         return w_set.copy()
 
     def difference_update(self, w_set, w_other):
@@ -896,9 +892,13 @@
 def set_difference__Set(space, w_left, others_w):
     if len(others_w) == 0:
         return w_left.copy()
-    result = w_left
+    result = w_left.copy()
     for w_other in others_w:
-        result = result.difference(w_other)
+        if isinstance(w_other, W_BaseSetObject):
+            result.difference_update(w_other)
+        else:
+            w_other_as_set = w_left._newobj(space, w_other)
+            result.difference_update(w_other_as_set)
     return result
 
 frozenset_difference__Frozenset = set_difference__Set


More information about the pypy-commit mailing list