From 49f3bf7401a3cc60a6105efebf92cb0004e26bfa Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Sun, 30 Jun 2019 20:09:26 +0300 Subject: [PATCH] Fix locals and globals in call to __import__ --- vm/src/vm.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vm/src/vm.rs b/vm/src/vm.rs index c8a131552..e4ccd8866 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -309,17 +309,20 @@ impl VirtualMachine { .get_attribute(self.builtins.clone(), "__import__") .map_err(|_| self.new_import_error("__import__ not found".to_string()))?; - let locals = if let Some(frame) = self.current_frame() { - frame.scope.get_locals().into_object() + let (locals, globals) = if let Some(frame) = self.current_frame() { + ( + frame.scope.get_locals().into_object(), + frame.scope.globals.clone().into_object(), + ) } else { - self.get_none() + (self.get_none(), self.get_none()) }; self.invoke( import_func, vec![ self.ctx.new_str(module.to_string()), + globals, locals, - self.get_none(), from_list.clone(), self.ctx.new_int(level), ],