|
14 | 14 | static inline NPY_DATETIMEUNIT |
15 | 15 | AK_dt_unit_from_array(PyArrayObject* a) { |
16 | 16 | // This is based on get_datetime_metadata_from_dtype in the NumPy source, but that function is private. This does not check that the dtype is of the appropriate type. |
17 | | - PyArray_DatetimeMetaData* dma = &(((PyArray_DatetimeDTypeMetaData *)PyArray_DESCR(a)->c_metadata)->meta); |
| 17 | + PyArray_Descr* dt = PyArray_DESCR(a); // borrowed ref |
| 18 | + PyArray_DatetimeMetaData* dma = &(((PyArray_DatetimeDTypeMetaData *)PyDataType_C_METADATA(dt))->meta); |
| 19 | + // PyArray_DatetimeMetaData* dma = &(((PyArray_DatetimeDTypeMetaData *)PyArray_DESCR(a)->c_metadata)->meta); |
18 | 20 | return dma->base; |
19 | 21 | } |
20 | 22 |
|
@@ -856,9 +858,9 @@ AK_TM_fill_object(TriMapObject* tm, |
856 | 858 | #define AK_TM_TRANSFER_FLEXIBLE(c_type) do { \ |
857 | 859 | Py_ssize_t one_count = from_src ? tm->src_one_count : tm->dst_one_count;\ |
858 | 860 | TriMapOne* one_pairs = from_src ? tm->src_one : tm->dst_one; \ |
859 | | - npy_intp t_element_size = PyArray_DESCR(array_to)->elsize; \ |
| 861 | + npy_intp t_element_size = PyArray_ITEMSIZE(array_to); \ |
860 | 862 | npy_intp t_element_cp = t_element_size / sizeof(c_type); \ |
861 | | - npy_intp f_element_size = PyArray_DESCR(array_from)->elsize; \ |
| 863 | + npy_intp f_element_size = PyArray_ITEMSIZE(array_from); \ |
862 | 864 | c_type* array_to_data = (c_type*)PyArray_DATA(array_to); \ |
863 | 865 | c_type* f; \ |
864 | 866 | c_type* t; \ |
@@ -906,7 +908,7 @@ AK_TM_fill_unicode(TriMapObject* tm, |
906 | 908 |
|
907 | 909 | Py_UCS4* array_to_data = (Py_UCS4*)PyArray_DATA(array_to); |
908 | 910 | // code points per element |
909 | | - npy_intp cp = PyArray_DESCR(array_to)->elsize / UCS4_SIZE; |
| 911 | + npy_intp cp = PyArray_ITEMSIZE(array_to) / UCS4_SIZE; |
910 | 912 |
|
911 | 913 | bool decref_fill_value = false; |
912 | 914 | if (PyBytes_Check(fill_value)) { |
@@ -948,7 +950,7 @@ AK_TM_fill_string(TriMapObject* tm, |
948 | 950 | ? tm->final_src_fill : tm->final_dst_fill); |
949 | 951 |
|
950 | 952 | char* array_to_data = (char*)PyArray_DATA(array_to); |
951 | | - npy_intp cp = PyArray_DESCR(array_to)->elsize; |
| 953 | + npy_intp cp = PyArray_ITEMSIZE(array_to); |
952 | 954 | if (!PyBytes_Check(fill_value)) { |
953 | 955 | return -1; |
954 | 956 | } |
|
0 commit comments