File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ mod fcntl {
5252 #[ cfg( any( target_os = "dragonfly" , target_os = "netbsd" , target_vendor = "apple" ) ) ]
5353 #[ pyattr]
5454 use libc:: F_GETPATH ;
55+ use rustpython_vm:: PyObjectRef ;
5556
5657 #[ pyfunction]
5758 fn fcntl (
@@ -89,12 +90,21 @@ mod fcntl {
8990
9091 #[ pyfunction]
9192 fn ioctl (
92- fd : i32 ,
93+ obj : PyObjectRef ,
9394 request : u32 ,
9495 arg : OptionalArg < Either < Either < ArgMemoryBuffer , ArgStrOrBytesLike > , i32 > > ,
9596 mutate_flag : OptionalArg < bool > ,
9697 vm : & VirtualMachine ,
9798 ) -> PyResult {
99+ let fd = obj. try_to_value ( vm) . or_else ( |_| {
100+ let meth = vm. get_method_or_type_error (
101+ obj. clone ( ) ,
102+ vm. ctx . interned_str ( "fileno" ) . unwrap ( ) ,
103+ || "ioctl first arg must be an int or object with a fileno() method" . to_owned ( ) ,
104+ ) ?;
105+ vm. invoke ( & meth, ( ) ) ?. try_into_value ( vm)
106+ } ) ?;
107+
98108 let arg = arg. unwrap_or_else ( || Either :: B ( 0 ) ) ;
99109 match arg {
100110 Either :: A ( buf_kind) => {
You can’t perform that action at this time.
0 commit comments