diff --git a/src/Mod/Path/App/AppPath.cpp b/src/Mod/Path/App/AppPath.cpp index eb7f6dbf9b..0fd8e771b3 100644 --- a/src/Mod/Path/App/AppPath.cpp +++ b/src/Mod/Path/App/AppPath.cpp @@ -58,7 +58,7 @@ PyMOD_INIT_FUNC(Path) } catch(const Base::Exception& e) { PyErr_SetString(PyExc_ImportError, e.what()); - return; + PyMOD_Return(NULL); } PyObject* pathModule = Path::initModule(); diff --git a/src/Mod/Path/App/AppPathPy.cpp b/src/Mod/Path/App/AppPathPy.cpp index 77edd6f389..cdf058024f 100644 --- a/src/Mod/Path/App/AppPathPy.cpp +++ b/src/Mod/Path/App/AppPathPy.cpp @@ -416,8 +416,12 @@ private: PyTuple_SetItem(ret,0,list); PyTuple_SetItem(ret,1,new Base::VectorPy( Base::Vector3d(pend.X(),pend.Y(),pend.Z()))); - if(need_arc_plane) + if(need_arc_plane) +#if PY_MAJOR_VERSION < 3 PyTuple_SetItem(ret,2,PyInt_FromLong(arc_plane)); +#else + PyTuple_SetItem(ret,2,PyLong_FromLong(arc_plane)); +#endif return Py::asObject(ret); } PATH_CATCH } diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index 2613662145..42a862ae6f 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -92,9 +92,13 @@ static PyObject * areaGetParamsDesc(PyObject *, PyObject *args, PyObject *kwd) { if (!PyArg_ParseTupleAndKeywords(args, kwd, "|O",kwlist,&pcObj)) return 0; +#if PY_MAJOR_VERSION < 3 if(PyObject_IsTrue(pcObj)) return PyString_FromString(PARAM_PY_DOC(NAME,AREA_PARAMS_STATIC_CONF)); - +#else + if(PyObject_IsTrue(pcObj)) + return PyUnicode_FromString(PARAM_PY_DOC(NAME,AREA_PARAMS_STATIC_CONF)); +#endif PyObject *dict = PyDict_New(); PARAM_PY_DICT_SET_DOC(dict,NAME,AREA_PARAMS_STATIC_CONF) return dict; diff --git a/src/Mod/Path/App/ParamsHelper.h b/src/Mod/Path/App/ParamsHelper.h index 0f9dd819fb..dccea8125d 100644 --- a/src/Mod/Path/App/ParamsHelper.h +++ b/src/Mod/Path/App/ParamsHelper.h @@ -858,9 +858,14 @@ #define PARAM_REF(_src,_seq) \ BOOST_PP_SEQ_FOR_EACH_I(PARAM_REF_,_src,_seq) +#if PY_MAJOR_VERSION < 3 + #define PARAM_CAST_PYOBJ_short(_v) PyInt_FromLong(_v) + #define PARAM_CAST_PYOBJ_long(_v) PyInt_FromLong(_v) +#else + #define PARAM_CAST_PYOBJ_short(_v) PyLong_FromLong(_v) + #define PARAM_CAST_PYOBJ_long(_v) PyLong_FromLong(_v) +#endif -#define PARAM_CAST_PYOBJ_short(_v) PyInt_FromLong(_v) -#define PARAM_CAST_PYOBJ_long(_v) PyInt_FromLong(_v) #define PARAM_CAST_PYOBJ_double(_v) PyFloat_FromDouble(_v) #define PARAM_CAST_PYOBJ_bool(_v) ((_v)?Py_True:Py_False) #define PARAM_CAST_PYOBJ_enum PARAM_CAST_PYOBJ_short @@ -870,9 +875,13 @@ /** Stringize field to a Python string * \ingroup ParamPy ParamStringizer */ +#if PY_MAJOR_VERSION < 3 #define PARAM_PY_STR(_field,_param) \ PyString_FromString(PARAM_FIELD_STR(_field,_param)) - +#else +#define PARAM_PY_STR(_field,_param) \ + PyUnicode_FromString(PARAM_FIELD_STR(_field,_param)) +#endif /** Helper for #PARAM_PY_DICT_SET_VALUE */ #define PARAM_PY_DICT_SET_VALUE_(_1,_args,_param) \ PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ @@ -920,10 +929,17 @@ #define PARAM_PY_DICT_DOC_enum2 PARAM_PY_DICT_DOC_enum /** Helper for #PARAM_PY_DICT_SET_DOC */ +#if PY_MAJOR_VERSION < 3 #define PARAM_PY_DICT_SET_DOC_(_1,_args,_param) \ PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ PARAM_PY_STR(BOOST_PP_TUPLE_ELEM(1,_args),_param),\ PyString_FromString(PARAM_TYPED(PARAM_PY_DICT_DOC_,_param)(_param))); +#else +#define PARAM_PY_DICT_SET_DOC_(_1,_args,_param) \ + PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ + PARAM_PY_STR(BOOST_PP_TUPLE_ELEM(1,_args),_param),\ + PyUnicode_FromString(PARAM_TYPED(PARAM_PY_DICT_DOC_,_param)(_param))); +#endif /** Populate a Python dict with the doc field of the parameter sequence *