summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-06-09 12:44:54 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-06-15 11:42:02 -0700
commit0af4c44b8f91bcb97276a82d6cd4dd8ad4d98fda (patch)
tree234f22a86f8323031eb35c793026ddf244e7cf0e
parent983277185ea595880697e9289796c527be28aab3 (diff)
downloadnumpy-0af4c44b8f91bcb97276a82d6cd4dd8ad4d98fda.tar.gz
REV: Revert casting part of the old changes
-rw-r--r--numpy/core/src/multiarray/array_assign_scalar.c7
-rw-r--r--numpy/core/src/multiarray/convert_datatype.h4
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,