[issue29116] Make str and bytes error messages on concatenation conform with other sequences

Jim Fasarakis-Hilliard report at bugs.python.org
Fri Dec 30 13:56:51 EST 2016


New submission from Jim Fasarakis-Hilliard:

Specifically, bytes (always, from what I could find) had this error message:

    >>> b'' + ''
    TypeError: can't concat bytes to str

while str, after a change in issue26057, was made to:

    >>> '' + b''
    TypeError: must be str, not bytes

from the previous form of "TypeError: Can't convert 'bytes' object to str implicitly".

I think these could be changed to conform with what the other sequences generate and fall in line with the error messages produced for other operations.

Specifically changing them to:

    >>> b'' + ''
    TypeError: can only concatenate bytes (not 'str') to bytes

and similarly for str.

If this idea makes sense, I can attach a patch that addresses it.

----------
components: Interpreter Core
messages: 284340
nosy: Jim Fasarakis-Hilliard
priority: normal
severity: normal
status: open
title: Make str and bytes error messages on concatenation conform with other sequences
type: behavior
versions: Python 3.6, Python 3.7

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


More information about the Python-bugs-list mailing list