summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Griffith <blake.a.griffith@gmail.com>2015-03-26 15:22:50 -0500
committerBlake Griffith <blake.a.griffith@gmail.com>2015-03-26 15:22:50 -0500
commit48c582fc733c3db1a7c25a505779ce4608e07a1a (patch)
treee414e6306af724c9f2642417256e007d216dba66
parent9713a276df05f16aa9b8b47f6a9418db1133a4ec (diff)
downloadnumpy-48c582fc733c3db1a7c25a505779ce4608e07a1a.tar.gz
BUG: Fix astype issue with custom dtypes
Using astype method to convert from custom dtypes should throw an OverflowError is the destination is too small. Previously it was segfaulting. closes bug 5719
-rw-r--r--numpy/core/src/multiarray/dtype_transfer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/dtype_transfer.c b/numpy/core/src/multiarray/dtype_transfer.c
index 7a7379ad5..f11ea395f 100644
--- a/numpy/core/src/multiarray/dtype_transfer.c
+++ b/numpy/core/src/multiarray/dtype_transfer.c
@@ -1362,6 +1362,13 @@ get_nbo_cast_transfer_function(int aligned,
break;
}
+ if (PyDataType_FLAGCHK(src_dtype, NPY_NEEDS_PYAPI) ||
+ PyDataType_FLAGCHK(dst_dtype, NPY_NEEDS_PYAPI)) {
+ if (out_needs_api) {
+ *out_needs_api = 1;
+ }
+ }
+
/* Get the cast function */
castfunc = PyArray_GetCastFunc(src_dtype, dst_dtype->type_num);
if (!castfunc) {