diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-11-23 02:20:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 02:20:13 +0100 |
| commit | 8b74aa6aa3cb3830ec0fc490d8fcee29e7c2a55e (patch) | |
| tree | ac274ae929b206f2485e74b2c3eb3dd6aaea52bf | |
| parent | 8ecbba97518db8e6b3d5fe09c80f869b85fb6264 (diff) | |
| parent | 7ac9fcbe76ac7129eae56ee0ef5c89f694965d12 (diff) | |
| download | numpy-8b74aa6aa3cb3830ec0fc490d8fcee29e7c2a55e.tar.gz | |
Merge pull request #22653 from ngoldbaum/ensure-canonical-check
MAINT: check user-defined dtype has an ensure_canonical implementation
| -rw-r--r-- | numpy/core/src/multiarray/experimental_public_dtype_api.c | 6 |
1 files changed, 6 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 f4133fd80..79261a9a7 100644 --- a/numpy/core/src/multiarray/experimental_public_dtype_api.c +++ b/numpy/core/src/multiarray/experimental_public_dtype_api.c @@ -209,6 +209,12 @@ PyArrayInitDTypeMeta_FromSpec( return -1; } + if (NPY_DT_SLOTS(DType)->ensure_canonical == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "A DType must provide an ensure_canonical implementation."); + return -1; + } + /* * Now that the spec is read we can check that all required functions were * defined by the user. |
