Skip to content

Commit

Permalink
Merge pull request RustPython#5405 from crazymerlyn/fix-set-intersect…
Browse files Browse the repository at this point in the history
…ion-update

Fix set intersection_update implementation
  • Loading branch information
coolreader18 authored Sep 20, 2024
2 parents b5c1fd9 + b36c95b commit 740aeed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 0 additions & 2 deletions Lib/test/test_weakset.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ def test_ixor(self):
else:
self.assertNotIn(c, self.s)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_inplace_on_self(self):
t = self.s.copy()
t |= t
Expand Down
12 changes: 3 additions & 9 deletions vm/src/builtins/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,10 @@ impl PySetInner {
others: impl std::iter::Iterator<Item = ArgIterable>,
vm: &VirtualMachine,
) -> PyResult<()> {
let mut temp_inner = self.copy();
let temp_inner = self.fold_op(others, PySetInner::intersection, vm)?;
self.clear();
for iterable in others {
for item in iterable.iter(vm)? {
let obj = item?;
if temp_inner.contains(&obj, vm)? {
self.add(obj, vm)?;
}
}
temp_inner = self.copy()
for obj in temp_inner.elements() {
self.add(obj, vm)?;
}
Ok(())
}
Expand Down

0 comments on commit 740aeed

Please sign in to comment.