Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:
Committed as r84301, r84302, and r84305.
--
keywords: -needs review
stage: patch review - committed/rejected
status: open - closed
versions: -Python 2.6
___
Python tracker
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
The patch looks good.
Feel free to apply.
--
assignee: rhettinger - stutzbach
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8750
Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
--
assignee: stutzbach - rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8750
___
Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
--
resolution: - accepted
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8750
___
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:
Patch with unit test attached for MutableSet's:
x ^= x
x -= x
I was wrong about |= and = having a problem. Since they don't mutate the set,
they don't raise an exception (they only .add items that are already in the
set).
New submission from Daniel Stutzbach dan...@stutzbachenterprises.com:
For example, here is one of MutableSet's methods:
def __isub__(self, it):
for value in it:
self.discard(value)
return self
However, if I do x -= x, then it mutates my set-like object during
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Here's a possible fix:
def __isub__(self, it):
if it is self:
self.clear()
else:
for value in it:
self.discard(value)
return self
--
nosy: +rhettinger
versions: +Python 2.6,