11#include <Python.h>
22
33#define PY_ARRAY_UNIQUE_SYMBOL asciidtype_ARRAY_API
4- #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
4+ #define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
5+ #define NPY_TARGET_VERSION NPY_2_0_API_VERSION
56#define NO_IMPORT_ARRAY
6- #include "numpy/arrayobject.h"
7- #include "numpy/experimental_dtype_api.h"
87#include "numpy/ndarraytypes.h"
8+ #include "numpy/arrayobject.h"
99#include "numpy/ufuncobject.h"
10+ #include "numpy/dtype_api.h"
1011
1112#include "dtype.h"
1213#include "string.h"
@@ -17,7 +18,7 @@ ascii_add_strided_loop(PyArrayMethod_Context *context, char *const data[],
1718 npy_intp const dimensions [], npy_intp const strides [],
1819 NpyAuxData * NPY_UNUSED (auxdata ))
1920{
20- PyArray_Descr * * descrs = context -> descriptors ;
21+ PyArray_Descr * const * descrs = context -> descriptors ;
2122 long in1_size = ((ASCIIDTypeObject * )descrs [0 ])-> size ;
2223 long in2_size = ((ASCIIDTypeObject * )descrs [1 ])-> size ;
2324 long out_size = ((ASCIIDTypeObject * )descrs [2 ])-> size ;
@@ -112,7 +113,7 @@ ascii_equal_strided_loop(PyArrayMethod_Context *context, char *const data[],
112113 npy_intp const dimensions [], npy_intp const strides [],
113114 NpyAuxData * NPY_UNUSED (auxdata ))
114115{
115- PyArray_Descr * * descrs = context -> descriptors ;
116+ PyArray_Descr * const * descrs = context -> descriptors ;
116117 long in1_size = ((ASCIIDTypeObject * )descrs [0 ])-> size ;
117118 long in2_size = ((ASCIIDTypeObject * )descrs [1 ])-> size ;
118119
@@ -218,12 +219,14 @@ init_equal_ufunc(PyObject *numpy)
218219 return 0 ;
219220}
220221
221- int
222+ PyObject *
222223init_ufuncs (void )
223224{
225+ import_umath ();
226+
224227 PyObject * numpy = PyImport_ImportModule ("numpy" );
225228 if (numpy == NULL ) {
226- return -1 ;
229+ return NULL ;
227230 }
228231
229232 if (init_add_ufunc (numpy ) < 0 ) {
@@ -234,10 +237,9 @@ init_ufuncs(void)
234237 goto error ;
235238 }
236239
237- Py_DECREF (numpy );
238- return 0 ;
240+ return numpy ;
239241
240242error :
241243 Py_DECREF (numpy );
242- return -1 ;
244+ return NULL ;
243245}
0 commit comments