This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author della
Recipients della
Date 2009-04-01.13:43:19
SpamBayes Score 8.903156e-12
Marked as misclassified No
Message-id <1238593402.02.0.427774935909.issue5647@psf.upfronthosting.co.za>
In-reply-to
Content
The current MutableSet.__iand__ implementation calls self.discard while
iterating on self. This creates strange problems while implementing
MutableSet with simple choices. For example, consider the attached file
which implements set by delegating either to a set or a list. In the
first cases, an exception is raised; in the second, the result is not
what is expected.

Python 2.6+ (r26:66714, Oct 22 2008, 09:21:39) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from simpleset import WithSet, WithList
>>> s = WithSet([1,2])
>>> s &= ()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/_abcoll.py", line 290, in __iand__
    for value in self:
RuntimeError: Set changed size during iteration
>>> s = WithList([1,2])
>>> s &= ()
>>> list(s)
[2]
History
Date User Action Args
2009-04-01 13:43:22dellasetrecipients: + della
2009-04-01 13:43:22dellasetmessageid: <1238593402.02.0.427774935909.issue5647@psf.upfronthosting.co.za>
2009-04-01 13:43:20dellalinkissue5647 messages
2009-04-01 13:43:20dellacreate