Issue with PyQt6 QByteArray

Detlev Offenbach detlev at die-offenbachs.de
Fri May 21 17:07:13 BST 2021


Am 20.05.21 um 18:11 schrieb Phil Thompson:
> On 18/05/2021 16:33, Detlev Offenbach wrote:
>> 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.
>
> Fixed in the next snapshot.
>
>
I am confirming this fix works as expected.

-- 
Detlev Offenbach
detlev at die-offenbachs.de



More information about the PyQt mailing list