Commit e805ecc7 authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 6573: Fix set.union() for cases where self is in the argument chain.

parent e7ac4f77
...@@ -82,6 +82,10 @@ class TestJointOps(unittest.TestCase): ...@@ -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')), set('abcef'))
self.assertEqual(self.thetype('abcba').union(C('ef'), C('fg')), set('abcefg')) 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): def test_or(self):
i = self.s.union(self.otherword) i = self.s.union(self.otherword)
self.assertEqual(self.s | set(self.otherword), i) self.assertEqual(self.s | set(self.otherword), i)
......
...@@ -14,6 +14,9 @@ Core and Builtins ...@@ -14,6 +14,9 @@ Core and Builtins
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters. - 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 - Issue #6070: On posix platforms import no longer copies the execute bit
from the .py file to the .pyc file if it is set. from the .py file to the .pyc file if it is set.
......
...@@ -1187,7 +1187,7 @@ set_union(PySetObject *so, PyObject *args) ...@@ -1187,7 +1187,7 @@ set_union(PySetObject *so, PyObject *args)
for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) { for (i=0 ; i<PyTuple_GET_SIZE(args) ; i++) {
other = PyTuple_GET_ITEM(args, i); other = PyTuple_GET_ITEM(args, i);
if ((PyObject *)so == other) if ((PyObject *)so == other)
return (PyObject *)result; continue;
if (set_update_internal(result, other) == -1) { if (set_update_internal(result, other) == -1) {
Py_DECREF(result); Py_DECREF(result);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment