mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Update sys module when stdlib_inits is changed
Provide `update_sysmodule` in vm to update sys when update_sysmodule changed
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user