File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 88
99#include " eigenpy/fwd.hpp"
1010
11+ #include < patchlevel.h> // For PY_MAJOR_VERSION
1112#include < numpy/arrayobject.h>
1213#include < iostream>
1314
@@ -93,11 +94,14 @@ namespace eigenpy
9394 NumpyType ()
9495 {
9596 pyModule = bp::import (" numpy" );
97+ #if PY_MAJOR_VERSION >= 3
98+ // TODO I don't know why this Py_INCREF is necessary.
99+ // Without it, the destructor of NumpyType SEGV sometimes.
100+ Py_INCREF (pyModule.ptr ());
101+ #endif
96102
97103 NumpyMatrixObject = pyModule.attr (" matrix" );
98104 NumpyMatrixType = reinterpret_cast <PyTypeObject*>(NumpyMatrixObject.ptr ());
99- NumpyAsMatrixObject = pyModule.attr (" asmatrix" );
100- NumpyAsMatrixType = reinterpret_cast <PyTypeObject*>(NumpyAsMatrixObject.ptr ());
101105 NumpyArrayObject = pyModule.attr (" ndarray" );
102106 NumpyArrayType = reinterpret_cast <PyTypeObject*>(NumpyArrayObject.ptr ());
103107
@@ -109,7 +113,6 @@ namespace eigenpy
109113
110114 // Numpy types
111115 bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
112- bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
113116 bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
114117 };
115118
You can’t perform that action at this time.
0 commit comments