From 274d09b5bb0088faeeb68a6b25d777fb32df1137 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Mon, 15 Apr 2019 18:16:56 +0200 Subject: [PATCH] Fix deletion of NumPy for Python 3 only. --- include/eigenpy/details.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index cdf1dfec..ed7a3cb5 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -8,6 +8,7 @@ #include "eigenpy/fwd.hpp" +#include <patchlevel.h> // For PY_MAJOR_VERSION #include <numpy/arrayobject.h> #include <iostream> @@ -93,9 +94,11 @@ 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<PyTypeObject*>(NumpyMatrixObject.ptr()); -- GitLab