Fixed list's __iadd__

When list iadd iterable value,
run iterator and add values to the list

Fixes #1475
This commit is contained in:
HyeockJinKim
2019-10-05 22:19:09 +09:00
parent 0ac9cb861c
commit 4468c81bc1

View File

@@ -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())