From a3c821062cb08b8b82f6bbd0dbaf6a51bc33acb5 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Thu, 11 Apr 2019 11:59:22 +0200 Subject: [PATCH] Fix SEGV with Python 3. --- include/eigenpy/details.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index 6c8058dc..cdf1dfec 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -93,11 +93,12 @@ namespace eigenpy NumpyType() { pyModule = bp::import("numpy"); + // TODO I don't know why this Py_INCREF is necessary. + // Without it, the destructor of NumpyType SEGV sometimes. + Py_INCREF(pyModule.ptr()); NumpyMatrixObject = pyModule.attr("matrix"); NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr()); - NumpyAsMatrixObject = pyModule.attr("asmatrix"); - NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr()); NumpyArrayObject = pyModule.attr("ndarray"); NumpyArrayType = reinterpret_cast<PyTypeObject*>(NumpyArrayObject.ptr()); @@ -109,7 +110,6 @@ namespace eigenpy // Numpy types bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType; - bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType; bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType; }; -- GitLab