diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 42a66dab4..19ad8b48f 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -209,6 +209,12 @@ impl VirtualMachine { vm } + /// `update_sysmodule` should be called when the `vm.stdlib_inits` are changed, + /// and then the `builtin_module_names` of `sys` module will be updated. + pub fn update_sysmodule(&self) { + sysmodule::make_module(self, self.sys_module.clone(), self.builtins.clone()); + } + pub fn run_code_obj(&self, code: PyCodeRef, scope: Scope) -> PyResult { let frame = Frame::new(code, scope).into_ref(self); self.run_frame_full(frame) diff --git a/wasm/lib/src/vm_class.rs b/wasm/lib/src/vm_class.rs index d3e060059..a1d95d4cb 100644 --- a/wasm/lib/src/vm_class.rs +++ b/wasm/lib/src/vm_class.rs @@ -44,6 +44,9 @@ impl StoredVirtualMachine { setup_browser_module(&vm); } + // sys module needs to be updated because js_module and browser_module is setted + vm.update_sysmodule(); + import::init_importlib(&vm, false).unwrap(); StoredVirtualMachine {