aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/PySide6/glue/qtcore.cpp2
-rw-r--r--sources/pyside6/tests/QtCore/qstring_test.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp
index 5d358800c..916ef4ba4 100644
--- a/sources/pyside6/PySide6/glue/qtcore.cpp
+++ b/sources/pyside6/PySide6/glue/qtcore.cpp
@@ -1278,7 +1278,7 @@ void *data = _PepUnicode_DATA(%in);
Py_ssize_t len = PyUnicode_GetLength(%in);
switch (_PepUnicode_KIND(%in)) {
case PepUnicode_1BYTE_KIND:
- %out = QString::fromLatin1(reinterpret_cast<const char *>(data));
+ %out = QString::fromLatin1(reinterpret_cast<const char *>(data), len);
break;
case PepUnicode_2BYTE_KIND:
%out = QString::fromUtf16(reinterpret_cast<const char16_t *>(data), len);
diff --git a/sources/pyside6/tests/QtCore/qstring_test.py b/sources/pyside6/tests/QtCore/qstring_test.py
index a43b2b94a..b694b4fef 100644
--- a/sources/pyside6/tests/QtCore/qstring_test.py
+++ b/sources/pyside6/tests/QtCore/qstring_test.py
@@ -52,6 +52,10 @@ class QStringConstructor(unittest.TestCase):
self.assertEqual(obj.objectName(), 'foo')
obj.setObjectName('áâãà')
self.assertEqual(obj.objectName(), 'áâãà')
+ obj.setObjectName('A\x00B')
+ self.assertEqual(obj.objectName(), 'A\x00B')
+ obj.setObjectName('ä\x00B')
+ self.assertEqual(obj.objectName(), 'ä\x00B')
obj.setObjectName(None)
self.assertEqual(obj.objectName(), '')