summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArink Verma <arinkverma@gmail.com>2013-07-10 20:53:47 +0530
committerArink Verma <arinkverma@gmail.com>2013-07-10 20:53:47 +0530
commit6815f865678e88dab68c00c34fb1c9e7166f8f3c (patch)
tree8cd41752623459ae93145fa103ba6e753bb3ac77
parent4c3ad43fc6cf68813bea09e1451f371f0a992369 (diff)
downloadnumpy-6815f865678e88dab68c00c34fb1c9e7166f8f3c.tar.gz
ENH: check for the same object in can_cast_scalar_to from convert_datatype.c
Check if two dtypes references to the same object in can_cast_scalar_to from convert_datatype.c, then the result is always OK
-rw-r--r--numpy/core/src/multiarray/convert_datatype.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c
index 8cdd65d7b..0d28ead89 100644
--- a/numpy/core/src/multiarray/convert_datatype.c
+++ b/numpy/core/src/multiarray/convert_datatype.c
@@ -719,7 +719,11 @@ can_cast_scalar_to(PyArray_Descr *scal_type, char *scal_data,
/* An aligned memory buffer large enough to hold any type */
npy_longlong value[4];
- if (casting == NPY_UNSAFE_CASTING) {
+ /*
+ * If the two dtypes are actually references to the same object
+ * or if casting type is forced unsafe then always OK.
+ */
+ if (scal_type == to || casting == NPY_UNSAFE_CASTING ) {
return 1;
}