Skip to content

Commit 5949a9b

Browse files
committed
fix io module being imported multiple times
1 parent aa48718 commit 5949a9b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vm/src/stdlib/io.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::collections::HashSet;
77
use std::fs::File;
88
use std::io::prelude::*;
99
use std::io::BufReader;
10+
use std::path::PathBuf;
1011

1112
//3rd party imports
1213
use num_bigint::ToBigInt;
@@ -23,6 +24,7 @@ use crate::pyobject::{
2324
PyResult, TypeProtocol,
2425
};
2526

27+
use crate::import;
2628
use crate::vm::VirtualMachine;
2729

2830
fn compute_c_flag(mode: &str) -> u16 {
@@ -267,7 +269,7 @@ pub fn io_open(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
267269
optional = [(mode, Some(vm.ctx.str_type()))]
268270
);
269271

270-
let module = mk_module(&vm.ctx);
272+
let module = import::import_module(vm, PathBuf::default(), "io").unwrap();
271273

272274
//mode is optional: 'rt' is the default mode (open from reading text)
273275
let rust_mode = mode.map_or("rt".to_string(), |m| objstr::get_value(m));

0 commit comments

Comments
 (0)