diff --git a/src/numpy_cpp.h b/src/numpy_cpp.h index f0608efa3bf4..f1b7ffaa015d 100644 --- a/src/numpy_cpp.h +++ b/src/numpy_cpp.h @@ -367,17 +367,19 @@ class array_view : public detail::array_view_accessors } } - array_view(const array_view &other, bool contiguous = false) : m_arr(NULL), m_data(NULL) + array_view(const array_view &other) : m_arr(NULL), m_data(NULL) { - if (!set((PyObject *)other.m_arr)) { - throw py::exception(); - } + m_arr = other.m_arr; + Py_XINCREF(m_arr); + m_data = other.m_data; + m_shape = other.m_shape; + m_strides = other.m_strides; } array_view(PyArrayObject *arr, char *data, npy_intp *shape, npy_intp *strides) { m_arr = arr; - Py_INCREF(arr); + Py_XINCREF(arr); m_data = data; m_shape = shape; m_strides = strides;