Skip to content
Snippets Groups Projects
Commit a3c82106 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Fix SEGV with Python 3.

parent b33a854f
No related branches found
No related tags found
No related merge requests found
...@@ -93,11 +93,12 @@ namespace eigenpy ...@@ -93,11 +93,12 @@ namespace eigenpy
NumpyType() NumpyType()
{ {
pyModule = bp::import("numpy"); 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"); NumpyMatrixObject = pyModule.attr("matrix");
NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr()); NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr());
NumpyAsMatrixObject = pyModule.attr("asmatrix");
NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());
NumpyArrayObject = pyModule.attr("ndarray"); NumpyArrayObject = pyModule.attr("ndarray");
NumpyArrayType = reinterpret_cast<PyTypeObject*>(NumpyArrayObject.ptr()); NumpyArrayType = reinterpret_cast<PyTypeObject*>(NumpyArrayObject.ptr());
...@@ -109,7 +110,6 @@ namespace eigenpy ...@@ -109,7 +110,6 @@ namespace eigenpy
// Numpy types // Numpy types
bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType; bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType; bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment