1.1 --- a/lib/__builtins__/set.py Sun Feb 05 18:17:14 2017 +0100
1.2 +++ b/lib/__builtins__/set.py Sun Feb 05 18:18:04 2017 +0100
1.3 @@ -239,7 +239,7 @@
1.4 "Remove from this set all values from 'other'."
1.5
1.6 for value in other:
1.7 - self.remove(value)
1.8 + self.discard(value)
1.9
1.10 def discard(self, value):
1.11
1.12 @@ -254,9 +254,14 @@
1.13
1.14 "Preserve in this set only values in this set found in 'other'."
1.15
1.16 + to_remove = set()
1.17 +
1.18 for value in self:
1.19 if value not in other:
1.20 - self.remove(value)
1.21 + to_remove.add(value)
1.22 +
1.23 + for value in to_remove:
1.24 + self.remove(value)
1.25
1.26 def pop(self):
1.27
2.1 --- a/tests/set.py Sun Feb 05 18:17:14 2017 +0100
2.2 +++ b/tests/set.py Sun Feb 05 18:18:04 2017 +0100
2.3 @@ -51,3 +51,20 @@
2.4 print 9 in aib # False
2.5 print 9 in adb # True
2.6 print 9 in asdb # False
2.7 +print
2.8 +
2.9 +aub2 = a.copy()
2.10 +aub2.update(b)
2.11 +print len(aub2) # 6
2.12 +
2.13 +aib2 = a.copy()
2.14 +aib2.intersection_update(b)
2.15 +print len(aib2) # 4
2.16 +
2.17 +adb2 = a.copy()
2.18 +adb2.difference_update(b)
2.19 +print len(adb2) # 1
2.20 +
2.21 +asdb2 = a.copy()
2.22 +asdb2.symmetric_difference_update(b)
2.23 +print len(asdb2) # 2