From 3efc4fee9e1b7af4f1ef486819d2a4a9a5021c93 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 28 Jan 2016 15:58:31 -0200 Subject: [PATCH] py3: python3-related fix in Spreadsheet --- src/Mod/Spreadsheet/App/SheetPyImp.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Mod/Spreadsheet/App/SheetPyImp.cpp b/src/Mod/Spreadsheet/App/SheetPyImp.cpp index bfca86f8c..0501c5eba 100644 --- a/src/Mod/Spreadsheet/App/SheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/SheetPyImp.cpp @@ -477,9 +477,18 @@ PyObject* SheetPy::setAlias(PyObject *args) try { address = stringToAddress(strAddress); - - if (PyString_Check(value)) + if (PyUnicode_Check(value)) +#if PY_MAJOR_VERSION >= 3 + getSheetPtr()->setAlias(address, PyUnicode_AsUTF8(value)); +#else + { + PyObject* unicode = PyUnicode_AsUTF8String(value); + v = QString::fromUtf8(PyString_AsString(unicode)); + Py_DECREF(unicode); + } + else if (PyString_Check(value)) getSheetPtr()->setAlias(address, PyString_AsString(value)); +#endif else if (value == Py_None) getSheetPtr()->setAlias(address, ""); else