diff options
| author | Nathan Goldbaum <nathan.goldbaum@gmail.com> | 2022-12-05 14:00:00 -0700 |
|---|---|---|
| committer | Nathan Goldbaum <nathan.goldbaum@gmail.com> | 2022-12-05 14:00:00 -0700 |
| commit | 7d4cfcfdbb3cab0cd7ab7460defd70ea34a6a25a (patch) | |
| tree | dd041b13f4f825363568bd40f6c5947bf72ec0ae /numpy | |
| parent | cfad62fd73c2a0f3d0dc4d73989071e331898a09 (diff) | |
| download | numpy-7d4cfcfdbb3cab0cd7ab7460defd70ea34a6a25a.tar.gz | |
MAINT: check if PyArrayDTypeMeta_Spec->casts is set
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/experimental_public_dtype_api.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/experimental_public_dtype_api.c b/numpy/core/src/multiarray/experimental_public_dtype_api.c index 79261a9a7..84507b481 100644 --- a/numpy/core/src/multiarray/experimental_public_dtype_api.c +++ b/numpy/core/src/multiarray/experimental_public_dtype_api.c @@ -258,6 +258,14 @@ PyArrayInitDTypeMeta_FromSpec( /* * And now, register all the casts that are currently defined! */ + if (spec->casts == NULL) { + PyErr_SetString( + PyExc_RuntimeError, + "DType must at least provide a function to cast (or just copy) " + "between its own instances!"); + return -1; + } + PyArrayMethod_Spec **next_meth_spec = spec->casts; while (1) { PyArrayMethod_Spec *meth_spec = *next_meth_spec; |
