Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix build failure and make Py2/Py3 specific change
- Loading branch information
Showing
1 changed file
with
9 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wwmayer
Author
Contributor
|
||
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 | ||
} | ||
} | ||
|
||
|
It's possible to use Py::Int in python3:
https://github.com/looooo/FreeCAD/blob/9d5ca8f79bd3dd39d7a5321e095e64816dca553b/src/CXX/Python3/Config.hxx#L132L134
https://github.com/looooo/FreeCAD/blob/9d5ca8f79bd3dd39d7a5321e095e64816dca553b/src/CXX/Python3/Objects.hxx#L800L802
just for your information. It's also fine with separating py2 and py3.