Skip to content

Commit d045fef

Browse files
committed
Merge pull request matplotlib#3811 from jbmohler/array_view_ctor
copy all array_view members in copy constructor
2 parents f05182d + bbff731 commit d045fef

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/numpy_cpp.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,19 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
367367
}
368368
}
369369

370-
array_view(const array_view &other, bool contiguous = false) : m_arr(NULL), m_data(NULL)
370+
array_view(const array_view &other) : m_arr(NULL), m_data(NULL)
371371
{
372-
if (!set((PyObject *)other.m_arr)) {
373-
throw py::exception();
374-
}
372+
m_arr = other.m_arr;
373+
Py_XINCREF(m_arr);
374+
m_data = other.m_data;
375+
m_shape = other.m_shape;
376+
m_strides = other.m_strides;
375377
}
376378

377379
array_view(PyArrayObject *arr, char *data, npy_intp *shape, npy_intp *strides)
378380
{
379381
m_arr = arr;
380-
Py_INCREF(arr);
382+
Py_XINCREF(arr);
381383
m_data = data;
382384
m_shape = shape;
383385
m_strides = strides;

0 commit comments

Comments
 (0)