mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Teach the sets module to correctly compute s-=s and s^=s as the empty set.
This commit is contained in:
parent
f98e6b15ba
commit
038ca2a551
2 changed files with 17 additions and 0 deletions
|
@ -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]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue