File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -250,7 +250,10 @@ impl VirtualMachine {
250
250
251
251
#[ cfg( any( not( target_arch = "wasm32" ) , target_os = "wasi" ) ) ]
252
252
{
253
- let io = self . import ( "io" , & [ ] , 0 ) ?;
253
+ // this isn't fully compatible with CPython; it imports "io" and sets
254
+ // builtins.open to io.OpenWrapper, but this is easier, since it doesn't
255
+ // require the Python stdlib to be present
256
+ let io = self . import ( "_io" , & [ ] , 0 ) ?;
254
257
let io_open = self . get_attribute ( io. clone ( ) , "open" ) ?;
255
258
let set_stdio = |name, fd, mode : & str | {
256
259
let stdio = self . invoke (
@@ -269,8 +272,7 @@ impl VirtualMachine {
269
272
set_stdio ( "stdout" , 1 , "w" ) ?;
270
273
set_stdio ( "stderr" , 2 , "w" ) ?;
271
274
272
- let open_wrapper = self . get_attribute ( io, "OpenWrapper" ) ?;
273
- self . set_attr ( & self . builtins , "open" , open_wrapper) ?;
275
+ self . set_attr ( & self . builtins , "open" , io_open) ?;
274
276
}
275
277
276
278
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments