diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index 6c8058dcb..ed7a3cb5c 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -8,6 +8,7 @@ #include "eigenpy/fwd.hpp" +#include // For PY_MAJOR_VERSION #include #include @@ -93,11 +94,14 @@ namespace eigenpy NumpyType() { pyModule = bp::import("numpy"); +#if PY_MAJOR_VERSION >= 3 + // TODO I don't know why this Py_INCREF is necessary. + // Without it, the destructor of NumpyType SEGV sometimes. + Py_INCREF(pyModule.ptr()); +#endif NumpyMatrixObject = pyModule.attr("matrix"); NumpyMatrixType = reinterpret_cast(NumpyMatrixObject.ptr()); - NumpyAsMatrixObject = pyModule.attr("asmatrix"); - NumpyAsMatrixType = reinterpret_cast(NumpyAsMatrixObject.ptr()); NumpyArrayObject = pyModule.attr("ndarray"); NumpyArrayType = reinterpret_cast(NumpyArrayObject.ptr()); @@ -109,7 +113,6 @@ namespace eigenpy // Numpy types bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType; - bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType; bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType; };