diff options
author | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:00:32 (GMT) |
---|---|---|
committer | Daniel Stutzbach <daniel@stutzbachenterprises.com> | 2010-08-24 21:00:32 (GMT) |
commit | e21624fb4558753ddc0b3fe2379d74d1f45f9d26 (patch) | |
tree | 5c3260285646444570caa840cadf563aaef649c3 /Lib/_abcoll.py | |
parent | ed2ce469f3bf4a0f6fb20761659ce6f5f2f3b399 (diff) | |
download | cpython-e21624fb4558753ddc0b3fe2379d74d1f45f9d26.zip cpython-e21624fb4558753ddc0b3fe2379d74d1f45f9d26.tar.gz cpython-e21624fb4558753ddc0b3fe2379d74d1f45f9d26.tar.bz2 |
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 d3e23c1..cac06e0 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) |