Backport of https://github.com/scribusproject/scribus/commit/065459990d1fe097d4339653c7ba600cc3547523 to fix https://bugzilla.redhat.com/2155514: Fails to build with Python 3.12: error: 'PyUnicode_AS_UNICODE' was not declared in this scope. --- scribus-1.5.8/scribus/plugins/scriptplugin/cmdgetsetprop.cpp +++ scribus-1.5.8/scribus/plugins/scriptplugin/cmdgetsetprop.cpp.python-3.12 @@ -409,10 +409,8 @@ success = obj->setProperty(propertyName, QString::fromUtf8(PyBytes_AsString(objValue))); else if (PyUnicode_Check(objValue)) { - // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted - const unsigned short * ucs2Data = (const unsigned short *) PyUnicode_AS_UNICODE(objValue); - // and make a new QString from it (the string is copied) - success = obj->setProperty(propertyName, QString::fromUtf16(ucs2Data)); + QString qStrValue = PyUnicode_asQString(objValue); + success = obj->setProperty(propertyName, qStrValue); } else matched = false; @@ -429,10 +427,8 @@ } else if (PyUnicode_Check(objValue)) { - // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted - const unsigned short * utf16Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue); - // and make a new QString from it (the string is copied) - success = obj->setProperty(propertyName, QString::fromUtf16(utf16Data).toLatin1()); + QString qStrValue = PyUnicode_asQString(objValue); + success = obj->setProperty(propertyName, qStrValue.toLatin1()); } else matched = false;