blob: 0e13892c7e26bfd767b51e9d57a0fac0bb60a9f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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;
|