Issue with PyQt6 QByteArray

Detlev Offenbach detlev at die-offenbachs.de
Tue May 18 16:33:03 BST 2021


Hello,

PyQt6.QtCore.QByteArray works faulty when copying the data from another 
QByteArray or a bytes object containing a zero character (\0) as oart of 
its contents. The resulting QByteArray only contains the data up to the 
zero. See following examples.

*PyQt5 (OK)*:
 >>> from PyQt5.QtCore import QByteArray
 >>> b=b'abc\0def'
 >>> b
b'abc\x00def'
 >>> ba=QByteArray(b)
 >>> ba
PyQt5.QtCore.QByteArray(b'abc\x00def')

*PyQt6 (faulty)*:
 >>> from PyQt6.QtCore import QByteArray
 >>> b=b'abc\0def'
 >>> b
b'abc\x00def'
 >>> ba=QByteArray(b)
 >>> ba
PyQt6.QtCore.QByteArray(b'abc')

*PySide6 (OK)*:
 >>> from PySide6.QtCore import QByteArray
 >>> b=b'abc\0def'
 >>> b
b'abc\x00def'
 >>> ba=QByteArray(b)
 >>> ba
PySide6.QtCore.QByteArray(b'abc\x00def')

This shows, that the issue is related to PyQt6 and not Qt6.

Regards
Detlev

-- 
Detlev Offenbach
detlev at die-offenbachs.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210518/95848066/attachment.htm>


More information about the PyQt mailing list