Skip to content

Commit d042ab2

Browse files
committed
Clone other to prevent borrow error
Clone other to prevent borrow error when self iadd to itself from list Fixes RustPython#1351
1 parent 93eea7c commit d042ab2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vm/src/obj/objlist.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ impl PyListRef {
146146

147147
fn iadd(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
148148
if objtype::isinstance(&other, &vm.ctx.list_type()) {
149-
self.elements
150-
.borrow_mut()
151-
.extend_from_slice(&get_elements_list(&other));
149+
let e = get_elements_list(&other).clone();
150+
self.elements.borrow_mut().extend_from_slice(&e);
152151
Ok(self.into_object())
153152
} else {
154153
Ok(vm.ctx.not_implemented())

0 commit comments

Comments
 (0)