From 69022a970cae79f3c1fe5aa87817afcfe3ca2936 Mon Sep 17 00:00:00 2001 From: Maarten Baert Date: Mon, 13 Apr 2026 13:23:30 +0200 Subject: [PATCH] BUG: incorrect temp elision for new-style (NEP 43) user-defined dtypes (#31193) Co-authored-by: Maarten Baert Co-authored-by: Sebastian Berg --- numpy/_core/include/numpy/ndarraytypes.h | 5 +++-- numpy/_core/src/multiarray/calculation.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/numpy/_core/include/numpy/ndarraytypes.h b/numpy/_core/include/numpy/ndarraytypes.h index f740788f3720..992fc1e2600e 100644 --- a/numpy/_core/include/numpy/ndarraytypes.h +++ b/numpy/_core/include/numpy/ndarraytypes.h @@ -1668,8 +1668,9 @@ PyArray_CLEARFLAGS(PyArrayObject *arr, int flags) ((type) <= NPY_LONGDOUBLE)) || \ ((type) == NPY_HALF)) -#define PyTypeNum_ISNUMBER(type) (((type) <= NPY_CLONGDOUBLE) || \ - ((type) == NPY_HALF)) +#define PyTypeNum_ISNUMBER(type) (((type) >= 0) && \ + (((type) <= NPY_CLONGDOUBLE) || \ + ((type) == NPY_HALF))) #define PyTypeNum_ISSTRING(type) (((type) == NPY_STRING) || \ ((type) == NPY_UNICODE)) diff --git a/numpy/_core/src/multiarray/calculation.c b/numpy/_core/src/multiarray/calculation.c index b95b37987f8e..a8e74401df76 100644 --- a/numpy/_core/src/multiarray/calculation.c +++ b/numpy/_core/src/multiarray/calculation.c @@ -829,7 +829,7 @@ NPY_NO_EXPORT PyObject * PyArray_Conjugate(PyArrayObject *self, PyArrayObject *out) { if (PyArray_ISCOMPLEX(self) || PyArray_ISOBJECT(self) || - PyArray_ISUSERDEF(self)) { + PyArray_ISUSERDEF(self) || !NPY_DT_is_legacy(PyArray_DESCR(self))) { if (out == NULL) { return PyArray_GenericUnaryFunction(self, n_ops.conjugate);