1111#include "numpy/arrayobject.h"
1212#include "numpy/ndarraytypes.h"
1313#include "numpy/dtype_api.h"
14- #include "numpy/_public_dtype_api_table.h" // not included in dtype_api.h
1514
1615#include "scalar.h"
1716#include "casts.h"
@@ -21,7 +20,6 @@ static inline int quad_load(Sleef_quad *x, char *data_ptr)
2120{
2221 if (data_ptr == NULL || x == NULL )
2322 {
24- PyErr_SetString (PyExc_ValueError , "Invalid memory location" );
2523 return -1 ;
2624 }
2725 * x = * (Sleef_quad * )data_ptr ;
@@ -32,7 +30,6 @@ static inline int quad_store(char *data_ptr, Sleef_quad x)
3230{
3331 if (data_ptr == NULL )
3432 {
35- PyErr_SetString (PyExc_ValueError , "Invalid memory location" );
3633 return -1 ;
3734 }
3835 * (Sleef_quad * )data_ptr = x ;
@@ -47,7 +44,6 @@ QuadPrecDTypeObject * new_quaddtype_instance(void)
4744 }
4845 new -> base .elsize = sizeof (Sleef_quad );
4946 new -> base .alignment = _Alignof(Sleef_quad );
50- new -> base .flags |= NPY_NEEDS_INIT ; // Indicates memory for this data-type must be initialized (set to 0) on creation.
5147
5248 return new ;
5349}
@@ -114,6 +110,9 @@ static int quadprec_setitem(QuadPrecDTypeObject *descr, PyObject *obj, char *dat
114110 if (quad_store (dataptr , value -> quad .value ) < 0 )
115111 {
116112 Py_DECREF (value );
113+ char error_msg [100 ];
114+ snprintf (error_msg , sizeof (error_msg ), "Invalid memory location %p" , (void * )dataptr );
115+ PyErr_SetString (PyExc_ValueError , error_msg );
117116 return -1 ;
118117 }
119118
@@ -131,6 +130,9 @@ static PyObject * quadprec_getitem(QuadPrecDTypeObject *descr, char *dataptr)
131130 if (quad_load (& new -> quad .value , dataptr ) < 0 )
132131 {
133132 Py_DECREF (new );
133+ char error_msg [100 ];
134+ snprintf (error_msg , sizeof (error_msg ), "Invalid memory location %p" , (void * )dataptr );
135+ PyErr_SetString (PyExc_ValueError , error_msg );
134136 return NULL ;
135137 }
136138 return (PyObject * )new ;
0 commit comments