@@ -18,6 +18,8 @@ use crate::pyobject::{
18
18
AttributeProtocol , IdProtocol , PyContext , PyFuncArgs , PyObject , PyObjectPayload , PyObjectRef ,
19
19
PyResult , Scope , TypeProtocol ,
20
20
} ;
21
+
22
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
21
23
use crate :: stdlib:: io:: io_open;
22
24
23
25
use crate :: vm:: VirtualMachine ;
@@ -702,7 +704,7 @@ fn builtin_sum(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
702
704
// builtin___import__
703
705
704
706
pub fn make_module ( ctx : & PyContext ) -> PyObjectRef {
705
- py_module ! ( ctx, "__builtins__" , {
707
+ let py_mod = py_module ! ( ctx, "__builtins__" , {
706
708
//set __name__ fixes: https://github.com/RustPython/RustPython/issues/146
707
709
"__name__" => ctx. new_str( String :: from( "__main__" ) ) ,
708
710
@@ -747,7 +749,6 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
747
749
"min" => ctx. new_rustfunc( builtin_min) ,
748
750
"object" => ctx. object( ) ,
749
751
"oct" => ctx. new_rustfunc( builtin_oct) ,
750
- "open" => ctx. new_rustfunc( io_open) ,
751
752
"ord" => ctx. new_rustfunc( builtin_ord) ,
752
753
"next" => ctx. new_rustfunc( builtin_next) ,
753
754
"pow" => ctx. new_rustfunc( builtin_pow) ,
@@ -789,7 +790,12 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
789
790
"StopIteration" => ctx. exceptions. stop_iteration. clone( ) ,
790
791
"ZeroDivisionError" => ctx. exceptions. zero_division_error. clone( ) ,
791
792
"KeyError" => ctx. exceptions. key_error. clone( ) ,
792
- } )
793
+ } ) ;
794
+
795
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
796
+ ctx. set_attr ( & py_mod, "open" , ctx. new_rustfunc ( io_open) ) ;
797
+
798
+ py_mod
793
799
}
794
800
795
801
pub fn builtin_build_class_ ( vm : & mut VirtualMachine , mut args : PyFuncArgs ) -> PyResult {
0 commit comments