diff options
-rw-r--r-- | numpy/core/src/multiarray/convert_datatype.c | 10 | ||||
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 11 |
2 files changed, 10 insertions, 11 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index 87b4fe7f8..b24869f89 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -415,19 +415,15 @@ PyArray_CanCastArrayTo(PyArrayObject *arr, PyArray_Descr *to, } /* Otherwise, check the value */ else { - char *data = PyArray_BYTES(arr); int swap = !PyArray_ISNBO(from->byteorder); int is_small_unsigned = 0, type_num; npy_bool ret; PyArray_Descr *dtype; /* An aligned memory buffer large enough to hold any type */ -#if NPY_SIZEOF_LONGLONG >= NPY_SIZEOF_CLONGDOUBLE - npy_longlong value; -#else - npy_clongdouble value; -#endif - from->f->copyswap(&value, data, swap, NULL); + npy_longlong value[4]; + + from->f->copyswap(&value, PyArray_BYTES(arr), swap, NULL); type_num = min_scalar_type_num((char *)&value, from->type_num, &is_small_unsigned); diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 539806ca9..e2e999b5b 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -957,10 +957,7 @@ ufunc_loop_matches(PyUFuncObject *self, * to the types for this function */ for (i = 0; i < nin; ++i) { - PyArray_Descr *tmp = PyArray_DescrFromType(types[i]); - if (tmp == NULL) { - return -1; - } + PyArray_Descr *tmp; /* * If no inputs are objects and there are more than one @@ -974,6 +971,12 @@ ufunc_loop_matches(PyUFuncObject *self, if (types[i] == NPY_OBJECT && !any_object && self->ntypes > 1) { return 0; } + + tmp = PyArray_DescrFromType(types[i]); + if (tmp == NULL) { + return -1; + } + #if NPY_UF_DBG_TRACING printf("Checking type for op %d, type %d: ", (int)i, (int)types[i]); PyObject_Print((PyObject *)tmp, stdout, 0); |