diff options
author | Blake Griffith <blake.a.griffith@gmail.com> | 2015-03-26 15:22:50 -0500 |
---|---|---|
committer | Blake Griffith <blake.a.griffith@gmail.com> | 2015-03-26 15:22:50 -0500 |
commit | 48c582fc733c3db1a7c25a505779ce4608e07a1a (patch) | |
tree | e414e6306af724c9f2642417256e007d216dba66 | |
parent | 9713a276df05f16aa9b8b47f6a9418db1133a4ec (diff) | |
download | numpy-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.c | 7 |
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) { |