diff --git a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp index fb94ca46f7..ae9e3d6c69 100644 --- a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp +++ b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp @@ -7,10 +7,6 @@ using namespace SpreadsheetGui; -#if PY_MAJOR_VERSION >= 2 -#define PyString_FromString PyUnicode_FromString -#endif - // returns a string which represents the object e.g. when printed in python std::string ViewProviderSpreadsheetPy::representation(void) const { @@ -24,10 +20,9 @@ PyObject* ViewProviderSpreadsheetPy::selectedRanges(PyObject* /*obj*/) SheetView *sheetView = vp->getView(); std::vector ranges = sheetView->selectedRanges(); PyObject *out = PyList_New(0); - std::vector::const_iterator i = ranges.begin(); - for (; i != ranges.end(); ++i) + for (const auto &range : ranges) { - PyObject *py_str = PyString_FromString(i->rangeString().c_str()); + PyObject *py_str = PyUnicode_FromString(range.rangeString().c_str()); PyList_Append(out, py_str); } @@ -40,9 +35,9 @@ PyObject* ViewProviderSpreadsheetPy::selectedCells(PyObject* /*obj*/) SheetView *sheetView = vp->getView(); QModelIndexList cells = sheetView->selectedIndexes(); PyObject *out = PyList_New(0); - for (auto it : cells) { - PyObject *py_str = PyString_FromString( - App::CellAddress(it.row(), it.column()).toString().c_str()); + for (const auto &cell : cells) { + PyObject *py_str = PyUnicode_FromString( + App::CellAddress(cell.row(), cell.column()).toString().c_str()); PyList_Append(out, py_str); } @@ -51,7 +46,7 @@ PyObject* ViewProviderSpreadsheetPy::selectedCells(PyObject* /*obj*/) PyObject *ViewProviderSpreadsheetPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; }