Commits

Ronald Oussoren committed bae7b41

Fix some edge cases in the set interface support.

Comments (0)

Files changed (1)

pyobjc-core/Lib/objc/_convenience_nsset.py

 collections.MutableSet.register(NSMutableSet)
 
 def nsset_isdisjoint(self, other):
+    if not hasattr(other, '__contains__'):
+        other = list(other)
+
     for item in self:
         if item in other:
             return False
 def nsset_intersection(self, *others):
     if len(others) == 0:
         return self.mutableCopy()
+
+    others = [o if hasattr(o, '__contains__') else list(o) for o in others]
+
     result = NSMutableSet()
     for item in self:
         for o in others:
 
 def nsset_symmetric_difference(self, other):
     result = NSMutableSet()
-    for item in self:
+    if not hasattr(other, '__contains__'):
+        other = list(other)
+    for item in iter(self):
         if item not in other:
             result.add(item)
     for item in other: