]> granicus.if.org Git - python/commitdiff
Issue 6573: Fix set.union() for cases where self is in the argument chain.
authorRaymond Hettinger <python@rcn.com>
Mon, 27 Jul 2009 20:16:37 +0000 (20:16 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 27 Jul 2009 20:16:37 +0000 (20:16 +0000)
Lib/test/test_set.py
Misc/NEWS
Objects/setobject.c

index a13f886aa32b26d5fbb7da73373e1b48250e7371..2b43a1614bd6a8bbbda7d64fc74332072e51a8f2 100644 (file)
@@ -82,6 +82,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)
index c15e5b69cfbfbeb1bab957d4753b9ea275761b6f..83aabb3afccf5d50398dbe1766b550a8d0a69c26 100644 (file)
--- 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.
 
index 8ecc405bc5f0c2ee18ca9a8a0a150f599c3e67dc..b296f9f329705cfc843460a46148742d93f4fdf6 100644 (file)
@@ -1187,7 +1187,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;