summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-08-03 19:31:56 +0300
committerGitHub <noreply@github.com>2020-08-03 19:31:56 +0300
commit2283e265990ba640c609982de57e17190c87f4b4 (patch)
tree0d340ad0af0db28de977344e50693e6db263572b
parent5d09976218ac10f197a99c3eb611c1d441f42a83 (diff)
parentc90ac6c6f9b0f2c06f3bf3c7a827fa783fe3e026 (diff)
downloadnumpy-2283e265990ba640c609982de57e17190c87f4b4.tar.gz
Merge pull request #16802 from seberg/user-dtypes-no-objects
MAINT: Explicitly disallow object user dtypes
-rw-r--r--numpy/core/src/multiarray/usertypes.c8
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;