@@ -13,7 +13,7 @@ use libffi::middle::{Arg, Cif, CodePtr, Type};
1313use libloading:: Symbol ;
1414use num_traits:: ToPrimitive ;
1515use rustpython_common:: lock:: PyRwLock ;
16- use std:: ffi:: { self , CString , c_void} ;
16+ use std:: ffi:: { self , c_void} ;
1717use std:: fmt:: Debug ;
1818
1919// See also: https://github.com/python/cpython/blob/4f8bb3947cfbc20f970ff9d9531e1132a9e95396/Modules/_ctypes/callproc.c#L15
@@ -61,6 +61,7 @@ impl ArgumentType for PyTypeRef {
6161
6262pub trait ReturnType {
6363 fn to_ffi_type ( & self ) -> Option < Type > ;
64+ #[ allow( clippy:: wrong_self_convention) ]
6465 fn from_ffi_type (
6566 & self ,
6667 value : * mut ffi:: c_void ,
@@ -197,9 +198,8 @@ impl Callable for PyCFuncPtr {
197198 let return_type = zelf. res_type . read ( ) ;
198199 let ffi_return_type = return_type
199200 . as_ref ( )
200- . map ( |t| ReturnType :: to_ffi_type ( & t. clone ( ) . downcast :: < PyType > ( ) . unwrap ( ) ) )
201- . flatten ( )
202- . unwrap_or_else ( || Type :: i32 ( ) ) ;
201+ . and_then ( |t| ReturnType :: to_ffi_type ( & t. clone ( ) . downcast :: < PyType > ( ) . unwrap ( ) ) )
202+ . unwrap_or_else ( Type :: i32) ;
203203 let cif = Cif :: new ( ffi_arg_types, ffi_return_type) ;
204204
205205 // Call the function
@@ -243,12 +243,12 @@ impl Representable for PyCFuncPtr {
243243 let index = zelf. ptr . read ( ) ;
244244 let index = index. map ( |ptr| ptr. 0 as usize ) . unwrap_or ( 0 ) ;
245245 let type_name = zelf. class ( ) . name ( ) ;
246- #[ cfg( windows) ]
247- {
246+ if cfg ! ( windows) {
248247 let index = index - 0x1000 ;
249- return Ok ( format ! ( "<COM method offset {index:#x} {type_name}>" ) ) ;
248+ Ok ( format ! ( "<COM method offset {index:#x} {type_name}>" ) )
249+ } else {
250+ Ok ( format ! ( "<{type_name} object at {index:#x}>" ) )
250251 }
251- Ok ( format ! ( "<{type_name} object at {index:#x}>" ) )
252252 }
253253}
254254
0 commit comments