py3: python3-related fix in Spreadsheet

This commit is contained in:
Yorik van Havre 2016-01-28 15:58:31 -02:00 committed by wmayer
parent 3d3a8d0141
commit 3efc4fee9e

View File

@ -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