diff --git a/tmva/pymva/src/MethodPyAdaBoost.cxx b/tmva/pymva/src/MethodPyAdaBoost.cxx index cb5e269c90df5..e7ce8c37f608f 100644 --- a/tmva/pymva/src/MethodPyAdaBoost.cxx +++ b/tmva/pymva/src/MethodPyAdaBoost.cxx @@ -24,6 +24,11 @@ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include +#if PY_VERSION_HEX >= 0x03000000 +#define PyString_FromString PyBytes_FromString +#define PyString_AsString PyBytes_AsString +#endif + #include "TMath.h" #include "Riostream.h" #include "TMatrix.h" diff --git a/tmva/pymva/src/MethodPyGTB.cxx b/tmva/pymva/src/MethodPyGTB.cxx index 4da61482ac8b2..ac9ec86a5762d 100644 --- a/tmva/pymva/src/MethodPyGTB.cxx +++ b/tmva/pymva/src/MethodPyGTB.cxx @@ -25,6 +25,11 @@ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include +#if PY_VERSION_HEX >= 0x03000000 +#define PyString_FromString PyBytes_FromString +#define PyString_AsString PyBytes_AsString +#endif + #include "TMath.h" #include "Riostream.h" #include "TMatrix.h" diff --git a/tmva/pymva/src/MethodPyRandomForest.cxx b/tmva/pymva/src/MethodPyRandomForest.cxx index b53504c22728f..8f4f4e2c73beb 100644 --- a/tmva/pymva/src/MethodPyRandomForest.cxx +++ b/tmva/pymva/src/MethodPyRandomForest.cxx @@ -24,6 +24,11 @@ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include +#if PY_VERSION_HEX >= 0x03000000 +#define PyString_FromString PyBytes_FromString +#define PyString_AsString PyBytes_AsString +#endif + #include "TMath.h" #include "Riostream.h" #include "TMatrix.h" diff --git a/tmva/pymva/src/PyMethodBase.cxx b/tmva/pymva/src/PyMethodBase.cxx index 84885af5fe3be..0d726e5b32d25 100644 --- a/tmva/pymva/src/PyMethodBase.cxx +++ b/tmva/pymva/src/PyMethodBase.cxx @@ -20,6 +20,10 @@ #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include +#if PY_VERSION_HEX >= 0x03000000 +#define PyString_FromString PyBytes_FromString +#endif + using namespace TMVA; @@ -133,7 +137,15 @@ void PyMethodBase::PyFinalize() } void PyMethodBase::PySetProgramName(TString name) { + #if PY_VERSION_HEX >= 0x03000000 + const char* char_name = const_cast(name.Data()); + const size_t size = strlen(char_name)+1; + wchar_t wchar_name[size]; + mbstowcs(wchar_name, char_name, size); + Py_SetProgramName(wchar_name); + #else Py_SetProgramName(const_cast(name.Data())); + #endif } //_______________________________________________________________________ TString PyMethodBase::Py_GetProgramName()