[New-bugs-announce] [issue30762] Misleading message “can't concat bytes to str”

Antoine Pietri report at bugs.python.org
Mon Jun 26 06:13:37 EDT 2017


New submission from Antoine Pietri:

>>> b'a' + 'a'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't concat bytes to str


This error message is misleading because it is reversed: what is really happening is that we're concatenating str to bytes! When you say "attach A to B" it means B is there first and A is added to it afterwards.

That said, we can't just reverse the message (“can't concat str to bytes”), because having the message reversed compared to the code would be also misleading.

I therefore propose to use “and” (→ “can't concat bytes and str”), which makes more sense and preserve the order.

----------
messages: 296870
nosy: antoine.pietri
priority: normal
severity: normal
status: open
title: Misleading message “can't concat bytes to str”

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


More information about the New-bugs-announce mailing list