@@ -168,7 +168,6 @@ pub struct CDataObject {
168168 pub objects : Option < PyObjectRef > ,
169169}
170170
171-
172171impl CDataObject {
173172 /// Create from StgInfo (CPython's PyCData_MallocBuffer pattern)
174173 pub fn from_stg_info ( stg_info : & StgInfo ) -> Self {
@@ -192,7 +191,13 @@ impl CDataObject {
192191
193192 /// Create from base object (copies data from base's buffer at offset)
194193 #[ allow( dead_code) ]
195- pub fn from_base ( base : PyObjectRef , _offset : usize , size : usize , index : usize , objects : Option < PyObjectRef > ) -> Self {
194+ pub fn from_base (
195+ base : PyObjectRef ,
196+ _offset : usize ,
197+ size : usize ,
198+ index : usize ,
199+ objects : Option < PyObjectRef > ,
200+ ) -> Self {
196201 CDataObject {
197202 buffer : vec ! [ 0u8 ; size] ,
198203 base : Some ( base) ,
@@ -222,26 +227,25 @@ impl PyCData {
222227}
223228
224229#[ pyclass( module = "_ctypes" , name = "PyCSimpleType" , base = PyType ) ]
225- #[ derive( Debug , PyPayload ) ]
226- #[ derive( Default ) ]
230+ #[ derive( Debug , PyPayload , Default ) ]
227231pub struct PyCSimpleType {
228232 pub stg_info : StgInfo ,
229233}
230234
231-
232235#[ pyclass( flags( BASETYPE ) , with( AsNumber ) ) ]
233236impl PyCSimpleType {
234237 /// Get stg_info for a simple type by reading _type_ attribute
235238 pub fn get_stg_info ( cls : & PyTypeRef , vm : & VirtualMachine ) -> StgInfo {
236239 if let Ok ( type_attr) = cls. as_object ( ) . get_attr ( "_type_" , vm)
237- && let Ok ( type_str) = type_attr. str ( vm) {
238- let tp_str = type_str . to_string ( ) ;
239- if tp_str . len ( ) == 1 {
240- let size = super :: _ctypes :: get_size ( & tp_str ) ;
241- let align = super :: _ctypes:: get_align ( & tp_str) ;
242- return StgInfo :: new ( size , align ) ;
243- }
240+ && let Ok ( type_str) = type_attr. str ( vm)
241+ {
242+ let tp_str = type_str . to_string ( ) ;
243+ if tp_str . len ( ) == 1 {
244+ let size = super :: _ctypes:: get_size ( & tp_str) ;
245+ let align = super :: _ctypes :: get_align ( & tp_str ) ;
246+ return StgInfo :: new ( size , align ) ;
244247 }
248+ }
245249 StgInfo :: default ( )
246250 }
247251 #[ allow( clippy:: new_ret_no_self) ]
0 commit comments