From fa5d1af7bb0842e62a8c5625212d2c7721816d78 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Wed, 25 Jan 2023 12:54:31 +0100 Subject: BUG: Fix crash when using complex double scalars with NEP 50 Not adding a test since there is already a test that crashes due to this, it just isn't used with weak promotion and right now I am hoping I may be able to make the test suite runnable enabling it. --- numpy/core/src/multiarray/abstractdtypes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/core/src/multiarray/abstractdtypes.h b/numpy/core/src/multiarray/abstractdtypes.h index b0850bd35..a3f6ceb05 100644 --- a/numpy/core/src/multiarray/abstractdtypes.h +++ b/numpy/core/src/multiarray/abstractdtypes.h @@ -58,7 +58,8 @@ npy_mark_tmp_array_if_pyscalar( } return 1; } - else if (PyComplex_Check(obj) && PyArray_TYPE(arr) == NPY_CDOUBLE) { + else if (PyComplex_Check(obj) && !PyArray_IsScalar(obj, CDouble) + && PyArray_TYPE(arr) == NPY_CDOUBLE) { ((PyArrayObject_fields *)arr)->flags |= NPY_ARRAY_WAS_PYTHON_COMPLEX; if (dtype != NULL) { Py_INCREF(&PyArray_PyComplexAbstractDType); -- cgit v1.2.1