summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-07-27 20:33:25 +0000
committerRaymond Hettinger <python@rcn.com>2009-07-27 20:33:25 +0000
commit30006c76f4acaaa66df47da697d900c369a892af (patch)
tree6532ef9856fab77f73c1ed153c38b5f9e893e7ff
parentda21dd076b8b06463ce9d2aebe1480ce1cf14083 (diff)
downloadcpython-git-30006c76f4acaaa66df47da697d900c369a892af.tar.gz
Issue 6573: Fix set.union() for cases where self is in the argument chain.
-rw-r--r--Lib/test/test_set.py4
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/setobject.c2
3 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 886c4b8db3..8a5f6602a8 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -81,6 +81,10 @@ class TestJointOps(unittest.TestCase):
self.assertEqual(self.thetype('abcba').union(C('ef')), set('abcef'))
self.assertEqual(self.thetype('abcba').union(C('ef'), C('fg')), set('abcefg'))
+ # Issue #6573
+ x = self.thetype()
+ self.assertEqual(x.union(set([1]), x, set([2])), self.thetype([1, 2]))
+
def test_or(self):
i = self.s.union(self.otherword)
self.assertEqual(self.s | set(self.otherword), i)
diff --git a/Misc/NEWS b/Misc/NEWS
index cbc07a14a9..3edf5572cb 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,9 @@ Core and Builtins
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
+- Issue #6573: set.union() stopped processing inputs if an instance of self
+ occurred in the argument chain.
+
- Issue #6070: On posix platforms import no longer copies the execute bit
from the .py file to the .pyc file if it is set.
diff --git a/Objects/setobject.c b/Objects/setobject.c
index a55bbb70ad..dd45380a35 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1183,7 +1183,7 @@ set_union(PySetObject *so, PyObject *args)
for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) {
other = PyTuple_GET_ITEM(args, i);
if ((PyObject *)so == other)
- return (PyObject *)result;
+ continue;
if (set_update_internal(result, other) == -1) {
Py_DECREF(result);
return NULL;