Simplify os.close

This commit is contained in:
Aviv Palivoda
2019-10-15 21:38:28 +03:00
parent a435bb1f81
commit 1ad9ee8792

View File

@@ -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)]