Issue with PyQt6 QByteArray

Phil Thompson phil at riverbankcomputing.com
Thu May 20 17:11:46 BST 2021


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.

Thanks,
Phil


More information about the PyQt mailing list