@@ -20,7 +20,7 @@ use crate::obj::objtype::{self, PyClassRef};
2020use crate :: frame:: Scope ;
2121use crate :: function:: { Args , OptionalArg , PyFuncArgs } ;
2222use crate :: pyobject:: {
23- DictProtocol , IdProtocol , PyContext , PyIterable , PyObjectRef , PyResult , PyValue , TryFromObject ,
23+ DictProtocol , IdProtocol , PyIterable , PyObjectRef , PyResult , PyValue , TryFromObject ,
2424 TypeProtocol ,
2525} ;
2626use crate :: vm:: VirtualMachine ;
@@ -668,13 +668,15 @@ fn builtin_import(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
668668
669669// builtin_vars
670670
671- pub fn make_module ( ctx : & PyContext ) -> PyObjectRef {
671+ pub fn make_module ( vm : & VirtualMachine , module : PyObjectRef ) {
672+ let ctx = & vm. ctx ;
673+
672674 #[ cfg( target_arch = "wasm32" ) ]
673- let open = ctx. none ( ) ;
675+ let open = vm . ctx . none ( ) ;
674676 #[ cfg( not( target_arch = "wasm32" ) ) ]
675- let open = ctx. new_rustfunc ( io_open) ;
677+ let open = vm . ctx . new_rustfunc ( io_open) ;
676678
677- py_module ! ( ctx , "__builtins__" , {
679+ extend_module ! ( vm , module , {
678680 //set __name__ fixes: https://github.com/RustPython/RustPython/issues/146
679681 "__name__" => ctx. new_str( String :: from( "__main__" ) ) ,
680682
@@ -765,7 +767,7 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
765767 "ZeroDivisionError" => ctx. exceptions. zero_division_error. clone( ) ,
766768 "KeyError" => ctx. exceptions. key_error. clone( ) ,
767769 "OSError" => ctx. exceptions. os_error. clone( ) ,
768- } )
770+ } ) ;
769771}
770772
771773pub fn builtin_build_class_ ( vm : & VirtualMachine , mut args : PyFuncArgs ) -> PyResult {
0 commit comments