mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
slight change
This commit is contained in:
@@ -868,11 +868,11 @@ pub fn os_ttyname(fd: PyIntRef, vm: &VirtualMachine) -> PyResult {
|
||||
use libc::ttyname;
|
||||
if let Some(fd) = fd.as_bigint().to_i32() {
|
||||
let name = unsafe { ttyname(fd) };
|
||||
if !name.is_null() {
|
||||
if name.is_null() {
|
||||
Err(vm.new_os_error(Error::last_os_error().to_string()))
|
||||
} else {
|
||||
let name = unsafe { CStr::from_ptr(name) }.to_str().unwrap();
|
||||
Ok(vm.ctx.new_str(name.to_owned()))
|
||||
} else {
|
||||
Err(vm.new_os_error(Error::last_os_error().to_string()))
|
||||
}
|
||||
} else {
|
||||
Err(vm.new_overflow_error("signed integer is greater than maximum".to_owned()))
|
||||
|
||||
Reference in New Issue
Block a user