diff options
author | Raymond Hettinger <python@rcn.com> | 2005-08-13 02:29:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-08-13 02:29:58 (GMT) |
commit | 038ca2a5516f6b445a8548f3999d1db3b6b8abb1 (patch) | |
tree | 3359f325b2eb27e8ed326bdac148d0de7ff62387 /Lib/sets.py | |
parent | f98e6b15bab7efb786ab65db63146afea388b022 (diff) | |
download | cpython-038ca2a5516f6b445a8548f3999d1db3b6b8abb1.zip cpython-038ca2a5516f6b445a8548f3999d1db3b6b8abb1.tar.gz cpython-038ca2a5516f6b445a8548f3999d1db3b6b8abb1.tar.bz2 |
Teach the sets module to correctly compute s-=s and s^=s as the empty set.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 8ec7e2f..32a0dd6 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -480,6 +480,8 @@ class Set(BaseSet): value = True if not isinstance(other, BaseSet): other = Set(other) + if self is other: + self.clear() for elt in other: if elt in data: del data[elt] @@ -497,6 +499,8 @@ class Set(BaseSet): data = self._data if not isinstance(other, BaseSet): other = Set(other) + if self is other: + self.clear() for elt in ifilter(data.has_key, other): del data[elt] |