fix build failure and make Py2/Py3 specific change

This commit is contained in:
wmayer
2017-05-15 22:36:21 +02:00
parent 7d47a723fb
commit dc413acc42

View File

@@ -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<std::string>(Py::String(edict.getItem("sErrMsg")));
if (edict.hasKey("iline"))
_line = static_cast<int>(Py::Long(edict.getItem("iline")));
#if PY_MAJOR_VERSION >= 3
_line = static_cast<long>(Py::Long(edict.getItem("iline")));
#else
_line = static_cast<int>(Py::Int(edict.getItem("iline")));
#endif
}
}