Comparing None with QByteArray starting with a null byte is inappropriate/inconsistent

Phil Thompson phil at riverbankcomputing.com
Wed Apr 23 09:28:23 BST 2025


On 23/04/2025 01:05, Maurizio Berti wrote:
> I just discovered that the following comparison behaves differently on
> PyQt5 and PyQt6:
> 
> None == QByteArray(b'\0')
> 
> In PyQt6 it properly returns False, but in PyQt5 it returns True, which 
> I
> believe wrong, especially since the result is unchanged no matter what
> follows that first byte, which is obviously inappropriate.
> 
> I tested only on 5.15.10 and 6.7.1.
> 
> Best regards,
> MaurizioB

PyQt5 and PyQt6 behave differently in many ways. If the PyQt5 behaviour 
is a bug then it will not be fixed - at this stage of its lifecycle 
consistency with earlier versions is more important than correctness.

Phil


More information about the PyQt mailing list