Skip to content

Commit a3c8210

Browse files
committed
Fix SEGV with Python 3.
1 parent b33a854 commit a3c8210

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/eigenpy/details.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ namespace eigenpy
9393
NumpyType()
9494
{
9595
pyModule = bp::import("numpy");
96+
// TODO I don't know why this Py_INCREF is necessary.
97+
// Without it, the destructor of NumpyType SEGV sometimes.
98+
Py_INCREF(pyModule.ptr());
9699

97100
NumpyMatrixObject = pyModule.attr("matrix");
98101
NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr());
99-
NumpyAsMatrixObject = pyModule.attr("asmatrix");
100-
NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());
101102
NumpyArrayObject = pyModule.attr("ndarray");
102103
NumpyArrayType = reinterpret_cast<PyTypeObject*>(NumpyArrayObject.ptr());
103104

@@ -109,7 +110,6 @@ namespace eigenpy
109110

110111
// Numpy types
111112
bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
112-
bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
113113
bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
114114
};
115115

0 commit comments

Comments
 (0)