[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons

Brett Cannon report at bugs.python.org
Thu May 1 16:58:59 CEST 2014


Brett Cannon added the comment:

Unfortunately it's impossible to warn against this in Python 2 since the bytes type is just another name for the str type:

>>> str == bytes
True
>>> type(b'1')
<type 'str'>

What we could potentially do, though, is change things such that -3 does what you are after when comparing bytes/str to unicode in Python 2. Unfortunately in that instance it's still a murky question as to whether that will help things more than hurt them as some people explicitly leave strings as-is in both Python 2 and Python 3 for either speed or code simplicity reasons.

----------
nosy: +brett.cannon
title: python2 -3 does not warn about str to bytes conversions and comparisons -> python2 -3 does not warn about str/unicode to bytes conversions and comparisons

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


More information about the Python-bugs-list mailing list