diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-07-11 09:54:38 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-07-11 09:54:38 -0500 |
commit | c90ac6c6f9b0f2c06f3bf3c7a827fa783fe3e026 (patch) | |
tree | 8ca85018ba4e9c938eb4ee20e71250cbf3e09eb6 | |
parent | 18a6e3e505ee416ddfc617f3e9afdff5a031c2c2 (diff) | |
download | numpy-c90ac6c6f9b0f2c06f3bf3c7a827fa783fe3e026.tar.gz |
MAINT: Explicitly disallow object user dtypes
These never worked to the best of my knowledge, so disable
it explicitly to hopefully simplify cleanup in other parts.
-rw-r--r-- | numpy/core/src/multiarray/usertypes.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/usertypes.c b/numpy/core/src/multiarray/usertypes.c index bc320138d..0c8d49970 100644 --- a/numpy/core/src/multiarray/usertypes.c +++ b/numpy/core/src/multiarray/usertypes.c @@ -211,6 +211,14 @@ PyArray_RegisterDataType(PyArray_Descr *descr) " is missing."); return -1; } + if (descr->flags & (NPY_ITEM_IS_POINTER | NPY_ITEM_REFCOUNT)) { + PyErr_SetString(PyExc_ValueError, + "Legacy user dtypes referencing python objects or generally " + "allocated memory are unsupported. " + "If you see this error in an existing, working code base, " + "please contact the NumPy developers."); + return -1; + } if (descr->typeobj == NULL) { PyErr_SetString(PyExc_ValueError, "missing typeobject"); return -1; |