Skip to content

Commit 86e94f5

Browse files
committed
Comment fix and use of i64 instead of i32
1 parent eca75b3 commit 86e94f5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

vm/src/stdlib/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn file_io_readinto(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
165165
let length = objint::get_value(&py_length.unwrap()).to_u64().unwrap();
166166

167167
let file_no = file_io.get_attr("fileno").unwrap();
168-
let raw_fd = objint::get_value(&file_no).to_i32().unwrap();
168+
let raw_fd = objint::get_value(&file_no).to_i64().unwrap();
169169

170170
//extract unix file descriptor.
171171
let handle = os::rust_file(raw_fd);
@@ -197,7 +197,7 @@ fn file_io_write(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
197197
);
198198

199199
let file_no = file_io.get_attr("fileno").unwrap();
200-
let raw_fd = objint::get_value(&file_no).to_i32().unwrap();
200+
let raw_fd = objint::get_value(&file_no).to_i64().unwrap();
201201

202202
//unsafe block - creates file handle from the UNIX file descriptor
203203
//raw_fd is supported on UNIX only. This will need to be extended

vm/src/stdlib/os.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@ use super::super::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeP
1616
use super::super::vm::VirtualMachine;
1717

1818
#[cfg(target_family = "unix")]
19-
pub fn raw_file_number(handle: File) -> i32 {
19+
pub fn raw_file_number(handle: File) -> i64 {
2020
use std::os::unix::io::IntoRawFd;
2121

22-
handle.into_raw_fd()
22+
handle.into_raw_fd() as i64
2323
}
2424

2525
#[cfg(target_family = "unix")]
26-
pub fn rust_file(raw_fileno: i32) -> File {
26+
pub fn rust_file(raw_fileno: i64) -> File {
2727
use std::os::unix::io::FromRawFd;
2828

29-
unsafe { File::from_raw_fd(raw_fileno) }
29+
unsafe { File::from_raw_fd(raw_fileno as i32) }
3030
}
3131

3232
#[cfg(target_family = "windows")]
33-
pub fn raw_file_number(handle: File) -> i32 {
33+
pub fn raw_file_number(handle: File) -> i64 {
3434
use std::os::windows::io::IntoRawHandle;
3535

36-
handle.into_raw_handle() as i32
36+
handle.into_raw_handle() as i64
3737
}
3838

3939
#[cfg(target_family = "windows")]
40-
pub fn rust_file(raw_fileno: i32) -> File {
40+
pub fn rust_file(raw_fileno: i64) -> File {
4141
use std::ffi::c_void;
4242
use std::os::windows::io::FromRawHandle;
4343

4444
//TODO: This is untested and (very) unsafe handling or
45-
//raw pointers - This should be patched as a matter of
46-
//urgently patched by comparison to the cpython handling of
47-
//the equivalent fileno fields for windows
45+
//raw pointers - This should be patched urgently by
46+
//comparison to the cpython handling of the equivalent fileno
47+
//fields for windows
4848
unsafe { File::from_raw_handle(raw_fileno as *mut c_void) }
4949
}
5050

@@ -56,7 +56,7 @@ pub fn os_close(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
5656
//The File type automatically closes when it goes out of scope.
5757
//To enable us to close these file desciptors (and hence prevent leaks)
5858
//we seek to create the relevant File and simply let it pass out of scope!
59-
rust_file(raw_fileno.to_i32().unwrap());
59+
rust_file(raw_fileno.to_i64().unwrap());
6060

6161
Ok(vm.get_none())
6262
}

0 commit comments

Comments
 (0)