@@ -17,9 +17,9 @@ use pyo3::{
1717} ;
1818
1919use crate :: npyffi:: {
20- self , NpyTypes , PyArray_Descr , PyDataType_ALIGNMENT , PyDataType_ELSIZE , PyDataType_FIELDS ,
21- PyDataType_FLAGS , PyDataType_NAMES , PyDataType_SUBARRAY , NPY_ALIGNED_STRUCT ,
22- NPY_BYTEORDER_CHAR , NPY_ITEM_HASOBJECT , NPY_TYPES , PY_ARRAY_API ,
20+ self , _PyDataType_GET_ITEM_DATA , NpyTypes , PyArray_Descr , PyDataType_ALIGNMENT ,
21+ PyDataType_ELSIZE , PyDataType_FIELDS , PyDataType_FLAGS , PyDataType_NAMES , PyDataType_SUBARRAY ,
22+ NPY_ALIGNED_STRUCT , NPY_BYTEORDER_CHAR , NPY_ITEM_HASOBJECT , NPY_TYPES , PY_ARRAY_API ,
2323} ;
2424
2525pub use num_complex:: { Complex32 , Complex64 } ;
@@ -159,7 +159,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
159159 /// [enumerated-types]: https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types
160160 /// [dtype-num]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.num.html
161161 fn num ( & self ) -> c_int {
162- unsafe { & * self . as_dtype_ptr ( ) } . type_num
162+ unsafe { & * _PyDataType_GET_ITEM_DATA ( self . as_dtype_ptr ( ) ) } . type_num
163163 }
164164
165165 /// Returns the element size of this type descriptor.
@@ -184,7 +184,9 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
184184 ///
185185 /// [dtype-byteorder]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.byteorder.html
186186 fn byteorder ( & self ) -> u8 {
187- unsafe { & * self . as_dtype_ptr ( ) } . byteorder . max ( 0 ) as _
187+ unsafe { & * _PyDataType_GET_ITEM_DATA ( self . as_dtype_ptr ( ) ) }
188+ . byteorder
189+ . max ( 0 ) as _
188190 }
189191
190192 /// Returns a unique ASCII character for each of the 21 different built-in types.
@@ -195,7 +197,9 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
195197 ///
196198 /// [dtype-char]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.char.html
197199 fn char ( & self ) -> u8 {
198- unsafe { & * self . as_dtype_ptr ( ) } . type_ . max ( 0 ) as _
200+ unsafe { & * _PyDataType_GET_ITEM_DATA ( self . as_dtype_ptr ( ) ) }
201+ . type_
202+ . max ( 0 ) as _
199203 }
200204
201205 /// Returns an ASCII character (one of `biufcmMOSUV`) identifying the general kind of data.
@@ -206,7 +210,9 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
206210 ///
207211 /// [dtype-kind]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html
208212 fn kind ( & self ) -> u8 {
209- unsafe { & * self . as_dtype_ptr ( ) } . kind . max ( 0 ) as _
213+ unsafe { & * _PyDataType_GET_ITEM_DATA ( self . as_dtype_ptr ( ) ) }
214+ . kind
215+ . max ( 0 ) as _
210216 }
211217
212218 /// Returns bit-flags describing how this type descriptor is to be interpreted.
@@ -330,7 +336,7 @@ impl<'py> PyArrayDescrMethods<'py> for Bound<'py, PyArrayDescr> {
330336 }
331337
332338 fn typeobj ( & self ) -> Bound < ' py , PyType > {
333- let dtype_type_ptr = unsafe { & * self . as_dtype_ptr ( ) } . typeobj ;
339+ let dtype_type_ptr = unsafe { & * _PyDataType_GET_ITEM_DATA ( self . as_dtype_ptr ( ) ) } . typeobj ;
334340 unsafe { PyType :: from_borrowed_type_ptr ( self . py ( ) , dtype_type_ptr) }
335341 }
336342
0 commit comments