[docs] [issue30435] Documentation either unclear or incorrect on comparisons between bytes and strings in Python 3

Martin Panter report at bugs.python.org
Tue May 23 02:11:26 EDT 2017


Martin Panter added the comment:

Also, “-bb” turns it into an exception, and the same applies to bytes vs int:

>>> b"a" == "a"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BytesWarning: Comparison between bytes and string
>>> b"a" == 0x61
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BytesWarning: Comparison between bytes and int

Perhaps the documentation should say “should not be compared” rather than “cannot”. Or perhaps it should mention “-b”.

Mariatta: I don’t think this is relevant to 2.7. In 2.7, you do get an error with bytearray vs unicode, but bytearray is not discussed in this bit of the Py 2 documentation.

----------
nosy: +Mariatta, martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30435>
_______________________________________


More information about the docs mailing list