Skip to content

Commit 274d09b

Browse files
committed
Fix deletion of NumPy for Python 3 only.
1 parent a3c8210 commit 274d09b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/eigenpy/details.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "eigenpy/fwd.hpp"
1010

11+
#include <patchlevel.h> // For PY_MAJOR_VERSION
1112
#include <numpy/arrayobject.h>
1213
#include <iostream>
1314

@@ -93,9 +94,11 @@ namespace eigenpy
9394
NumpyType()
9495
{
9596
pyModule = bp::import("numpy");
97+
#if PY_MAJOR_VERSION >= 3
9698
// TODO I don't know why this Py_INCREF is necessary.
9799
// Without it, the destructor of NumpyType SEGV sometimes.
98100
Py_INCREF(pyModule.ptr());
101+
#endif
99102

100103
NumpyMatrixObject = pyModule.attr("matrix");
101104
NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr());

0 commit comments

Comments
 (0)