diff options
author | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:00:32 +0000 |
---|---|---|
committer | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:00:32 +0000 |
commit | 2cf86be66a394722652dbae3598ad0fda8c507a4 (patch) | |
tree | c44ef0c2ccb353783a3859b63c41b86e5a6d83fc /Lib/_abcoll.py | |
parent | 12458c05339704fceab7bfe0fb86526504467e15 (diff) | |
download | cpython-2cf86be66a394722652dbae3598ad0fda8c507a4.tar.gz |
Merged revisions 84301 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84301 | daniel.stutzbach | 2010-08-24 15:49:57 -0500 (Tue, 24 Aug 2010) | 1 line
Issue 8750: Fixed MutableSet's methods to correctly handle reflexive operations, namely x -= x and x ^= x
........
Diffstat (limited to 'Lib/_abcoll.py')
-rw-r--r-- | Lib/_abcoll.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index d3e23c1e44..cac06e0825 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -321,18 +321,24 @@ class MutableSet(Set): return self def __ixor__(self, it: Iterable): - if not isinstance(it, Set): - it = self._from_iterable(it) - for value in it: - if value in self: - self.discard(value) - else: - self.add(value) + if it is self: + self.clear() + else: + if not isinstance(it, Set): + it = self._from_iterable(it) + for value in it: + if value in self: + self.discard(value) + else: + self.add(value) return self def __isub__(self, it: Iterable): - for value in it: - self.discard(value) + if it is self: + self.clear() + else: + for value in it: + self.discard(value) return self MutableSet.register(set) |