mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Fix locals and globals in call to __import__
This commit is contained in:
1 parent
a332b74ad8
commit
49f3bf7401
1 file changed
+7
-4
+7
-4
@@ -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),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user