diff --git a/src/App/FeaturePythonPyImp.h b/src/App/FeaturePythonPyImp.h index dd570e34f6..104c16d6d5 100644 --- a/src/App/FeaturePythonPyImp.h +++ b/src/App/FeaturePythonPyImp.h @@ -103,8 +103,8 @@ public: //@{ static int __setattro(PyObject *PyObj, PyObject *attro, PyObject *value); //@} - PyObject *_getattr(char *attr); // __getattr__ function - int _setattr(char *attr, PyObject *value); // __setattr__ function + PyObject *_getattr(const char *attr); // __getattr__ function + int _setattr(const char *attr, PyObject *value); // __setattr__ function protected: PyObject * dict_methods; diff --git a/src/App/FeaturePythonPyImp.inl b/src/App/FeaturePythonPyImp.inl index 9f7f09fa93..f9b36edb12 100644 --- a/src/App/FeaturePythonPyImp.inl +++ b/src/App/FeaturePythonPyImp.inl @@ -104,7 +104,7 @@ FeaturePythonPyT::~FeaturePythonPyT() template int FeaturePythonPyT::__setattro(PyObject *obj, PyObject *attro, PyObject *value) { - char *attr; + const char *attr; #if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); #else @@ -127,7 +127,7 @@ int FeaturePythonPyT::__setattro(PyObject *obj, PyObject *attro, PyO template -int FeaturePythonPyT::_setattr(char *attr, PyObject *value) +int FeaturePythonPyT::_setattr(const char *attr, PyObject *value) { App::Property *prop = FeaturePyT::getPropertyContainerPtr()->getPropertyByName(attr); if (prop && !value) { @@ -162,7 +162,7 @@ int FeaturePythonPyT::_setattr(char *attr, PyObject *value) } template -PyObject *FeaturePythonPyT::_getattr(char *attr) +PyObject *FeaturePythonPyT::_getattr(const char *attr) { // See CallTipsList::extractTips if (Base::streq(attr, "__fc_template__")) { diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 1f3105524d..2c2dc9e974 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -141,7 +141,7 @@ PyMethodDef PyObjectBase::Methods[] = { PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) { - char *attr; + const char *attr; #if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); #else @@ -195,7 +195,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value) { - char *attr; + const char *attr; #if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); #else @@ -236,7 +236,7 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value) /*------------------------------ * PyObjectBase attributes -- attributes ------------------------------*/ -PyObject *PyObjectBase::_getattr(char *attr) +PyObject *PyObjectBase::_getattr(const char *attr) { if (streq(attr, "__class__")) { // Note: We must return the type object here, @@ -279,7 +279,7 @@ PyObject *PyObjectBase::_getattr(char *attr) } } -int PyObjectBase::_setattr(char *attr, PyObject *value) +int PyObjectBase::_setattr(const char *attr, PyObject *value) { if (streq(attr,"softspace")) return -1; // filter out softspace diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index e72ecae03d..7c8fc60f07 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -231,7 +231,7 @@ public: * need to call the method of the base class! Otherwise even the * methods of the object will disappear! */ - virtual PyObject *_getattr(char *attr); + virtual PyObject *_getattr(const char *attr); /// static wrapper for pythons _getattro() static PyObject *__getattro(PyObject * PyObj, PyObject *attro); @@ -241,7 +241,7 @@ public: * this method. * You have to call the method of the base class. */ - virtual int _setattr(char *attro, PyObject *value); // _setattr method + virtual int _setattr(const char *attro, PyObject *value); // _setattr method /// static wrapper for pythons _setattro(). // This should be the entry in Type. static int __setattro(PyObject *PyObj, PyObject *attro, PyObject *value); diff --git a/src/CXX/IndirectPythonInterface.cxx b/src/CXX/IndirectPythonInterface.cxx index dd63bf3562..0147cfa3d9 100644 --- a/src/CXX/IndirectPythonInterface.cxx +++ b/src/CXX/IndirectPythonInterface.cxx @@ -549,7 +549,7 @@ PYCXX_EXPORT int &_Py_InteractiveFlag() { return Py_InteractiveFlag PYCXX_EXPORT int &_Py_OptimizeFlag() { return Py_OptimizeFlag; } PYCXX_EXPORT int &_Py_NoSiteFlag() { return Py_NoSiteFlag; } PYCXX_EXPORT int &_Py_VerboseFlag() { return Py_VerboseFlag; } -PYCXX_EXPORT char *__Py_PackageContext() { return _Py_PackageContext; } +PYCXX_EXPORT const char *__Py_PackageContext() { return _Py_PackageContext; } // // Needed to keep the abstactions for delayload interface diff --git a/src/CXX/Python2/IndirectPythonInterface.hxx b/src/CXX/Python2/IndirectPythonInterface.hxx index 6c4e4f0dac..5080717915 100644 --- a/src/CXX/Python2/IndirectPythonInterface.hxx +++ b/src/CXX/Python2/IndirectPythonInterface.hxx @@ -193,7 +193,7 @@ PYCXX_EXPORT int &_Py_UnicodeFlag(); PYCXX_EXPORT void _XINCREF( PyObject *op ); PYCXX_EXPORT void _XDECREF( PyObject *op ); -PYCXX_EXPORT char *__Py_PackageContext(); +PYCXX_EXPORT const char *__Py_PackageContext(); } #endif // __CXX_INDIRECT_PYTHON_INTERFACE__HXX__ diff --git a/src/CXX/Python3/IndirectPythonInterface.hxx b/src/CXX/Python3/IndirectPythonInterface.hxx index a4c0cf424c..97e34e3d3f 100644 --- a/src/CXX/Python3/IndirectPythonInterface.hxx +++ b/src/CXX/Python3/IndirectPythonInterface.hxx @@ -178,7 +178,7 @@ PYCXX_EXPORT int &_Py_UnicodeFlag(); PYCXX_EXPORT void _XINCREF( PyObject *op ); PYCXX_EXPORT void _XDECREF( PyObject *op ); -PYCXX_EXPORT char *__Py_PackageContext(); +PYCXX_EXPORT const char *__Py_PackageContext(); }; #endif // __CXX_INDIRECT_PYTHON_INTERFACE__HXX__ diff --git a/src/Gui/PythonWorkbenchPyImp.cpp b/src/Gui/PythonWorkbenchPyImp.cpp index 7084c80ae2..bcedc47e42 100644 --- a/src/Gui/PythonWorkbenchPyImp.cpp +++ b/src/Gui/PythonWorkbenchPyImp.cpp @@ -64,7 +64,7 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) PyObject* item = PyList_GetItem(pPath, j); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); path.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); @@ -81,7 +81,7 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) } } else if (PyUnicode_Check(pPath)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(pPath); + const char* pItem = PyUnicode_AsUTF8(pPath); path.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(pPath, "utf-8", 0); @@ -106,7 +106,7 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) PyObject* item = PyList_GetItem(pItems, i); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); @@ -123,7 +123,7 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) } } else if (PyUnicode_Check(pItems)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(pItems); + const char* pItem = PyUnicode_AsUTF8(pItems); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(pItems, "utf-8", 0); @@ -199,7 +199,7 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) PyObject* item = PyList_GetItem(pPath, j); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); path.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); @@ -216,7 +216,7 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) } } else if (PyUnicode_Check(pPath)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(pPath); + const char* pItem = PyUnicode_AsUTF8(pPath); path.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(pPath, "utf-8", 0); @@ -241,7 +241,7 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) PyObject* item = PyList_GetItem(pItems, i); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); @@ -258,7 +258,7 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) } } else if (PyUnicode_Check(pItems)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(pItems); + const char* pItem = PyUnicode_AsUTF8(pItems); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(pItems, "utf-8", 0); @@ -313,7 +313,7 @@ PyObject* PythonWorkbenchPy::appendToolbar(PyObject *args) PyObject* item = PyList_GetItem(pObject, i); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); @@ -389,7 +389,7 @@ PyObject* PythonWorkbenchPy::appendCommandbar(PyObject *args) PyObject* item = PyList_GetItem(pObject, i); if (PyUnicode_Check(item)) { #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); #else PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 9ddf1510b2..625a7e7811 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -1437,7 +1437,7 @@ Py::Object PyResource::setValue(const Py::Tuple& args) #endif continue; #if PY_MAJOR_VERSION >= 3 - char* pItem = PyUnicode_AsUTF8(item); + const char* pItem = PyUnicode_AsUTF8(item); #else char* pItem = PyString_AsString(item); #endif diff --git a/src/Mod/Part/App/TopologyPy.cpp b/src/Mod/Part/App/TopologyPy.cpp index 01f885e9de..bfd1af59f5 100644 --- a/src/Mod/Part/App/TopologyPy.cpp +++ b/src/Mod/Part/App/TopologyPy.cpp @@ -190,7 +190,7 @@ TopoShapePyOld::~TopoShapePyOld() // Everything handled in parent //-------------------------------------------------------------------------- // TopoShapePyOld Attributes //-------------------------------------------------------------------------- -PyObject *TopoShapePyOld::_getattr(char *attr) // __getattr__ function: note only need to handle new state +PyObject *TopoShapePyOld::_getattr(const char *attr) // __getattr__ function: note only need to handle new state { try{ // Access the number of attributes at this label @@ -205,7 +205,7 @@ PyObject *TopoShapePyOld::_getattr(char *attr) // __getattr__ function: note } } -int TopoShapePyOld::_setattr(char *attr, PyObject *value) // __setattr__ function: note only need to handle new state +int TopoShapePyOld::_setattr(const char *attr, PyObject *value) // __setattr__ function: note only need to handle new state { if (Base::streq(attr, "Real")) // settable new state ; @@ -712,4 +712,4 @@ PyObject *TopoShapePyOld::exportSTL(PyObject *args) Py_Return; } -#endif \ No newline at end of file +#endif diff --git a/src/Mod/Part/App/TopologyPy.h b/src/Mod/Part/App/TopologyPy.h index 070a197e5b..030a22c633 100644 --- a/src/Mod/Part/App/TopologyPy.h +++ b/src/Mod/Part/App/TopologyPy.h @@ -72,9 +72,9 @@ public: //--------------------------------------------------------------------- virtual PyObject *_repr(void); // the representation - PyObject *_getattr(char *attr); // __getattr__ function + PyObject *_getattr(const char *attr); // __getattr__ function // getter setter - int _setattr(char *attr, PyObject *value); // __setattr__ function + int _setattr(const char *attr, PyObject *value); // __setattr__ function // methods PYFUNCDEF_D (TopoShapePyOld,hasChild); diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 728aafbdb6..4d4e1b8f3e 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -224,8 +224,8 @@ public: /// setter for special attributes (e.g. dynamic ones) /// Output: Success=1, Failure=-1, Ignore=0 int setCustomAttributes(const char* attr, PyObject *obj); - PyObject *_getattr(char *attr); // __getattr__ function - int _setattr(char *attr, PyObject *value); // __setattr__ function + PyObject *_getattr(const char *attr); // __getattr__ function + int _setattr(const char *attr, PyObject *value); // __setattr__ function - /// getter for the object handled by this class @@ -727,7 +727,7 @@ PyObject *@self.export.Name@::_repr(void) //-------------------------------------------------------------------------- // @self.export.Name@ Attributes //-------------------------------------------------------------------------- -PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: note only need to handle new state +PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ function: note only need to handle new state { try { // getter method for special Attributes (e.g. dynamic ones) @@ -795,7 +795,7 @@ PyObject *@self.export.Name@::_getattr(char *attr) // __getattr__ function: n return @self.export.Father@::_getattr(attr); } -int @self.export.Name@::_setattr(char *attr, PyObject *value) // __setattr__ function: note only need to handle new state +int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr__ function: note only need to handle new state { try { // setter for special Attributes (e.g. dynamic ones)