Commit 2d313304 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub

Merge pull request #58 from jmirabel/devel

Fix SEGV with Python 3.
parents b33a854f 274d09b5
......@@ -8,6 +8,7 @@
#include "eigenpy/fwd.hpp"
#include <patchlevel.h> // For PY_MAJOR_VERSION
#include <numpy/arrayobject.h>
#include <iostream>
......@@ -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<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 +113,6 @@ namespace eigenpy
// Numpy types
bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment