[New-bugs-announce] [issue21401] python2 -3 does not warn about str to bytes conversions and comparisons

Joshua J Cogliati report at bugs.python.org
Wed Apr 30 20:00:16 CEST 2014


New submission from Joshua J Cogliati:

The -3 option should warn about str to bytes conversions and str to bytes comparisons:
For example in Python 3 the following happens:

python3
Python 3.3.2 <snip>
Type "help", "copyright", "credits" or "license" for more information.
>>> b"a" + "a"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't concat bytes to str
>>> b"a" == "a"
False
>>> 

But even python2 -3 does not warn about either of these uses:

python2 -3
Python 2.7.5 <snip>
Type "help", "copyright", "credits" or "license" for more information.
>>> b"a" + "a"
'aa'
>>> b"a" == "a"
True
>>> u"a" + "a"
u'aa'
>>> u"a" == "a"
True
>>> 

These two issues are some of the more significant problems I have in trying get python2 code working with python3, and if -3 does not warn about it this is harder to do.

----------
components: Unicode
messages: 217633
nosy: Joshua.J.Cogliati, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: python2 -3 does not warn about str to bytes conversions and comparisons
versions: Python 2.7

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


More information about the New-bugs-announce mailing list