Skip to content

Fix errors related to missing PyInt_AsLong and PyString_AsString on Python 3

Gregory Lee requested to merge grlee77/vtk:py3_fixes into release

This PR fixes a compilation error I was getting when compiling with 7.0.0 RC2 with Python 3.4 on a 64-bit linux machine when -DModule_vtkRenderingMatplotlib=ON. Compilation succeeds with the following changes, but I haven't used the module in practice.

e.g.

vtkMatplotlibMathTextUtilities.cxx:98:54: error: ‘PyString_AsString’ was not declared in this scope
           PyString_AsString(tracebackStr.GetPointer())))

vtkMatplotlibMathTextUtilities.cxx:725:77: error: ‘PyInt_AsLong’ was not declared in this scope
       const unsigned char val = static_cast<unsigned char>(PyInt_AsLong(item));

for reference, I ran cmake as follows:

cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/lee8rx/anaconda/envs/_build -DCMAKE_INSTALL_RPATH:STRING=/home/lee8rx/anaconda/envs/_build/lib -DBUILD_DOCUMENTATION=OFF -DVTK_HAS_FEENABLEEXCEPT=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DVTK_WRAP_PYTHON=ON -DPYTHON_EXECUTABLE=/home/lee8rx/anaconda/envs/_build/bin/python -DPYTHON_INCLUDE_PATH=/home/lee8rx/anaconda/envs/_build/include/python3.4m -DPYTHON_LIBRARY=/home/lee8rx/anaconda/envs/_build/lib/libpython3.4m.so -DVTK_INSTALL_PYTHON_MODULE_DIR=/home/lee8rx/anaconda/envs/_build/lib/python3.4/site-packages -DModule_vtkRenderingMatplotlib=ON -DVTK_USE_X=ON -DVTK_PYTHON_VERSION=3

Merge request reports