mirror of https://github.com/python/cpython
merge
This commit is contained in:
commit
d702044bcd
|
@ -1742,6 +1742,19 @@ class TestWeirdBugs(unittest.TestCase):
|
||||||
s.update(range(100))
|
s.update(range(100))
|
||||||
list(si)
|
list(si)
|
||||||
|
|
||||||
|
def test_merge_and_mutate(self):
|
||||||
|
class X:
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(0)
|
||||||
|
def __eq__(self, o):
|
||||||
|
other.clear()
|
||||||
|
return False
|
||||||
|
|
||||||
|
other = set()
|
||||||
|
other = {X() for i in range(10)}
|
||||||
|
s = {0}
|
||||||
|
s.update(other)
|
||||||
|
|
||||||
# Application tests (based on David Eppstein's graph recipes ====================================
|
# Application tests (based on David Eppstein's graph recipes ====================================
|
||||||
|
|
||||||
def powerset(U):
|
def powerset(U):
|
||||||
|
|
|
@ -34,6 +34,8 @@ Core and Builtins
|
||||||
|
|
||||||
- Issue #24569: Make PEP 448 dictionary evaluation more consistent.
|
- Issue #24569: Make PEP 448 dictionary evaluation more consistent.
|
||||||
|
|
||||||
|
- Issue #24583: Fix crash when set is mutated while being updated.
|
||||||
|
|
||||||
- Issue #24407: Fix crash when dict is mutated while being updated.
|
- Issue #24407: Fix crash when dict is mutated while being updated.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
|
|
|
@ -668,7 +668,8 @@ set_merge(PySetObject *so, PyObject *otherset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't assure there are no duplicates, so do normal insertions */
|
/* We can't assure there are no duplicates, so do normal insertions */
|
||||||
for (i = 0; i <= other->mask; i++, other_entry++) {
|
for (i = 0; i <= other->mask; i++) {
|
||||||
|
other_entry = &other->table[i];
|
||||||
key = other_entry->key;
|
key = other_entry->key;
|
||||||
if (key != NULL && key != dummy) {
|
if (key != NULL && key != dummy) {
|
||||||
if (set_add_entry(so, key, other_entry->hash))
|
if (set_add_entry(so, key, other_entry->hash))
|
||||||
|
|
Loading…
Reference in New Issue