forked from Rust-related/RustPython
Simplify os.close
This commit is contained in:
@@ -83,11 +83,11 @@ fn make_path(_vm: &VirtualMachine, path: PyStringRef, dir_fd: &DirFd) -> PyStrin
|
||||
}
|
||||
}
|
||||
|
||||
fn os_close(fileno: PyIntRef, _vm: &VirtualMachine) {
|
||||
fn os_close(fileno: i64, _vm: &VirtualMachine) {
|
||||
//The File type automatically closes when it goes out of scope.
|
||||
//To enable us to close these file descriptors (and hence prevent leaks)
|
||||
//we seek to create the relevant File and simply let it pass out of scope!
|
||||
rust_file(fileno.as_bigint().to_i64().unwrap());
|
||||
//we seek to create the relevant File and simply drop it.
|
||||
drop(rust_file(fileno));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user