Details
-
Bug
-
Resolution: Done
-
P4: Low
-
None
-
6.3.0
-
None
-
Python 3.9 - Ubuntu 20.04
-
-
f2b4abb43e (pyside/pyside-setup/dev) 5fea947741 (pyside/pyside-setup/6.3) 5fea947741 (pyside/tqtc-pyside-setup/6.3) f2b4abb43e (pyside/tqtc-pyside-setup/dev)
Description
According to the Qt6 documentation, embedded NULL characters are allowed in a QString:
"A QString can embed '\0' characters (QChar::Null). The size() function always returns the size of the whole string, including embedded '\0' characters."
Also, Unicode strings in Python can contain NULL characters. So obviously nothing prevents the under-layer QString and the Pythonic equivalent str instance from containing NULL characters and it's OK to have them in a string as they are valid characters.
To ensure the under-layer Qt interface handles embedded NULL characters in a string properly when working with a QPlainTextEdit (or a QTextEdit) I coded a simple program in C++ that indicates it works properly. Please check the attached C++ file "main.cpp" to reproduce.
However, the PySide6 equivalent of the program fails! It truncates the string passed to QPlainTextEdit.setPlainText() up to the first NULL character in the string resulting in data integrity loss. Please check the attached Python file "main.py" to reproduce.
PyUnicode_PythonToCpp_QString len= 3 _PepUnicode_KIND= 1 PyUnicode_PythonToCpp_QString lat= "A"
Attachments
Issue Links
- relates to
-
PYSIDE-1882 QPlainTextEdit.setPlainText raises ValueError if the Unicode string contains NULL characters
- Closed