From dc413acc429f6b0ae0ef100ca4e5a4efe35930a0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 15 May 2017 22:36:21 +0200 Subject: [PATCH] fix build failure and make Py2/Py3 specific change --- src/Base/Exception.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Base/Exception.cpp b/src/Base/Exception.cpp index cdf61d248f2d..b8c535cd4da8 100644 --- a/src/Base/Exception.cpp +++ b/src/Base/Exception.cpp @@ -109,7 +109,11 @@ PyObject * Exception::getPyObject(void) edict.setItem("sclassname", Py::String(typeid(*this).name())); edict.setItem("sErrMsg", Py::String(this->getMessage())); edict.setItem("sfile", Py::String(this->getFile())); +#if PY_MAJOR_VERSION >= 3 edict.setItem("iline", Py::Long(this->getLine())); +#else + edict.setItem("iline", Py::Int(this->getLine())); +#endif edict.setItem("sfunction", Py::String(this->getFunction())); edict.setItem("swhat", Py::String(this->what())); return Py::new_reference_to(edict); @@ -129,7 +133,11 @@ void Exception::setPyObject( PyObject * pydict) _sErrMsg = static_cast(Py::String(edict.getItem("sErrMsg"))); if (edict.hasKey("iline")) - _line = static_cast(Py::Long(edict.getItem("iline"))); +#if PY_MAJOR_VERSION >= 3 + _line = static_cast(Py::Long(edict.getItem("iline"))); +#else + _line = static_cast(Py::Int(edict.getItem("iline"))); +#endif } }