From 4468c81bc17eabb88cb2186e2dc2999ac15bb651 Mon Sep 17 00:00:00 2001 From: HyeockJinKim Date: Sat, 5 Oct 2019 22:19:09 +0900 Subject: [PATCH] Fixed list's __iadd__ When list iadd iterable value, run iterator and add values to the list Fixes #1475 --- vm/src/obj/objlist.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vm/src/obj/objlist.rs b/vm/src/obj/objlist.rs index 0afb44e39..d27593ebe 100644 --- a/vm/src/obj/objlist.rs +++ b/vm/src/obj/objlist.rs @@ -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())