mirror of
https://github.com/python/cpython
synced 2024-09-19 15:01:28 +00:00
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 ........
This commit is contained in:
parent
ed2ce469f3
commit
e21624fb45
|
@ -321,18 +321,24 @@ def __iand__(self, it: Iterable):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __ixor__(self, it: Iterable):
|
def __ixor__(self, it: Iterable):
|
||||||
if not isinstance(it, Set):
|
if it is self:
|
||||||
it = self._from_iterable(it)
|
self.clear()
|
||||||
for value in it:
|
else:
|
||||||
if value in self:
|
if not isinstance(it, Set):
|
||||||
self.discard(value)
|
it = self._from_iterable(it)
|
||||||
else:
|
for value in it:
|
||||||
self.add(value)
|
if value in self:
|
||||||
|
self.discard(value)
|
||||||
|
else:
|
||||||
|
self.add(value)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __isub__(self, it: Iterable):
|
def __isub__(self, it: Iterable):
|
||||||
for value in it:
|
if it is self:
|
||||||
self.discard(value)
|
self.clear()
|
||||||
|
else:
|
||||||
|
for value in it:
|
||||||
|
self.discard(value)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
MutableSet.register(set)
|
MutableSet.register(set)
|
||||||
|
|
|
@ -494,6 +494,21 @@ def __repr__(self):
|
||||||
s = MySet([5,43,2,1])
|
s = MySet([5,43,2,1])
|
||||||
self.assertEqual(s.pop(), 1)
|
self.assertEqual(s.pop(), 1)
|
||||||
|
|
||||||
|
def test_issue8750(self):
|
||||||
|
empty = WithSet()
|
||||||
|
full = WithSet(range(10))
|
||||||
|
s = WithSet(full)
|
||||||
|
s -= s
|
||||||
|
self.assertEqual(s, empty)
|
||||||
|
s = WithSet(full)
|
||||||
|
s ^= s
|
||||||
|
self.assertEqual(s, empty)
|
||||||
|
s = WithSet(full)
|
||||||
|
s &= s
|
||||||
|
self.assertEqual(s, full)
|
||||||
|
s |= s
|
||||||
|
self.assertEqual(s, full)
|
||||||
|
|
||||||
def test_Mapping(self):
|
def test_Mapping(self):
|
||||||
for sample in [dict]:
|
for sample in [dict]:
|
||||||
self.assertTrue(isinstance(sample(), Mapping))
|
self.assertTrue(isinstance(sample(), Mapping))
|
||||||
|
|
|
@ -95,6 +95,9 @@ C-API
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #8750: Fixed MutableSet's methods to correctly handle
|
||||||
|
reflexive operations, namely x -= x and x ^= x.
|
||||||
|
|
||||||
- Issue #9129: smtpd.py is vulnerable to DoS attacks deriving from missing
|
- Issue #9129: smtpd.py is vulnerable to DoS attacks deriving from missing
|
||||||
error handling when accepting a new connection.
|
error handling when accepting a new connection.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue