Skip to content

Fix errors related to missing PyInt_AsLong and PyString_AsString on Python 3

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

This is a resubmission of !1080 (closed), but based off of the release branch. It has also been updated to use _PyUnicode_AsString for Python 3.0-3.2, and PyUnicode_AsUTF8 only for Python 3.3+

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));

Merge request reports