Python 3 returns "False" when comparing bytes and string objects.
>>> b'' == ''
False
Is there a way to force the interpreter raise an exception instead? Maybe some flag when invoking python3?
Passing the -b flag to Python3 will emit a warning when comparing bytes and strings. Passing -bb
will raise an exception.
$ python3 -c "b'' == '' "
$ python3 -bc "b'' == '' "
<string>:1: BytesWarning: Comparison between bytes and string
$ python3 -bbc "b'' == '' "
Traceback (most recent call last):
File "<string>", line 1, in <module>
BytesWarning: Comparison between bytes and string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With