Skip to content

Commit

Permalink
fix build failure and make Py2/Py3 specific change
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 15, 2017
1 parent 7d47a72 commit dc413ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Base/Exception.cpp
Expand Up @@ -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.

Copy link
@looooo

This comment has been minimized.

Copy link
@wwmayer

wwmayer May 16, 2017

Author Contributor

But why did we put all the effort into adding the Py2 <> Py3 changes, then?

This comment has been minimized.

Copy link
@looooo

looooo May 16, 2017

Contributor

in my case it was because of ignorance. I didn't know about this precompiler definition when I started to work on python3. The definition only solves PyCxx long vs int. With pure python types separating py2 / py3 code is still necessary.

edict.setItem("sfunction", Py::String(this->getFunction()));
edict.setItem("swhat", Py::String(this->what()));
return Py::new_reference_to(edict);
Expand All @@ -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
}
}

Expand Down

0 comments on commit dc413ac

Please sign in to comment.