Skip to content

Commit 739bc8d

Browse files
committed
Avoid set changed size during iteration
1 parent e41d7f5 commit 739bc8d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Lib/test/test_set.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,6 @@ def test_ixor(self):
582582
else:
583583
self.assertNotIn(c, self.s)
584584

585-
# TODO: RUSTPYTHON
586-
@unittest.expectedFailure
587585
def test_inplace_on_self(self):
588586
t = self.s.copy()
589587
t |= t

vm/src/builtins/set.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@ impl PySetInner {
425425
vm: &VirtualMachine,
426426
) -> PyResult<()> {
427427
for iterable in others {
428-
for item in iterable.iter(vm)? {
429-
self.content.delete_if_exists(vm, &*item?)?;
428+
let items = iterable.iter(vm)?.collect::<Result<Vec<_>, _>>()?;
429+
for item in items {
430+
self.content.delete_if_exists(vm, &*item)?;
430431
}
431432
}
432433
Ok(())

0 commit comments

Comments
 (0)