summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorGagandeep Singh <gdp.1807@gmail.com>2021-11-10 22:27:45 +0530
committerGagandeep Singh <gdp.1807@gmail.com>2021-11-10 22:27:45 +0530
commitd0d75f39f28ac26d4cc1aa3a4cbea63a6a027929 (patch)
treecd8a04f5f768209afabeb4542e7c491091d9048c /numpy
parent2db65c9db122d780462c6fdcd8d54b85c6631365 (diff)
downloadnumpy-d0d75f39f28ac26d4cc1aa3a4cbea63a6a027929.tar.gz
Reverted dead code removal
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/ctors.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index dd92f715c..286e45e39 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -1881,7 +1881,16 @@ PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth,
if ((requires & NPY_ARRAY_ELEMENTSTRIDES) &&
!PyArray_ElementStrides(obj)) {
- PyErr_SetString(PyExc_RuntimeError, "Not Implemented.");
+ PyObject *ret;
+ if (requires & NPY_ARRAY_ENSURENOCOPY) {
+ PyErr_SetString(PyExc_ValueError,
+ "Unable to avoid copy "
+ "while creating a new array.");
+ return NULL;
+ }
+ ret = PyArray_NewCopy((PyArrayObject *)obj, NPY_ANYORDER);
+ Py_DECREF(obj);
+ obj = ret;
}
return obj;
}