Fixed list's __iadd__
When list iadd iterable value,
run iterator and add values to the list
Fixes
@@ -145,9 +145,9 @@ impl PyListRef {
}
fn iadd(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
- if objtype::isinstance(&other, &vm.ctx.list_type()) {
- let e = get_elements_list(&other).clone();
- self.elements.borrow_mut().extend_from_slice(&e);
+ if let Ok(new_elements) = vm.extract_elements(&other) {
+ let mut e = new_elements;
+ self.elements.borrow_mut().append(&mut e);
Ok(self.into_object())
} else {
Ok(vm.ctx.not_implemented())
