diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/array_assign_scalar.c | 7 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/convert_datatype.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/array_assign_scalar.c b/numpy/core/src/multiarray/array_assign_scalar.c index e2bffd655..ba964b86d 100644 --- a/numpy/core/src/multiarray/array_assign_scalar.c +++ b/numpy/core/src/multiarray/array_assign_scalar.c @@ -243,11 +243,8 @@ PyArray_AssignRawScalar(PyArrayObject *dst, } /* Check the casting rule */ - // TODO: This is incorrect, we need the information if the input was a - // Python scalar?! Or rather, we want a "inspect" cast-safety - // so to speak. A special scalar assignment just for this purpose - // _probably_ that should be handled earlier, though! - if (!PyArray_CanCastTypeTo(src_dtype, PyArray_DESCR(dst), casting)) { + if (!can_cast_scalar_to(src_dtype, src_data, + PyArray_DESCR(dst), casting)) { npy_set_invalid_cast_error( src_dtype, PyArray_DESCR(dst), casting, NPY_TRUE); return -1; diff --git a/numpy/core/src/multiarray/convert_datatype.h b/numpy/core/src/multiarray/convert_datatype.h index 1a2f91337..f5951e8f0 100644 --- a/numpy/core/src/multiarray/convert_datatype.h +++ b/numpy/core/src/multiarray/convert_datatype.h @@ -51,6 +51,10 @@ PyArray_ValidType(int type); NPY_NO_EXPORT int dtype_kind_to_ordering(char kind); +NPY_NO_EXPORT npy_bool +can_cast_scalar_to(PyArray_Descr *scal_type, char *scal_data, + PyArray_Descr *to, NPY_CASTING casting); + /* Used by PyArray_CanCastArrayTo and in the legacy ufunc type resolution */ NPY_NO_EXPORT npy_bool can_cast_scalar_to(PyArray_Descr *scal_type, char *scal_data, |
