[issue29116] Make str and bytes error messages on concatenation conform with other sequences
Jim Fasarakis-Hilliard
report at bugs.python.org
Fri Dec 30 16:53:37 EST 2016
Jim Fasarakis-Hilliard added the comment:
Should that message be the one predominantly used for sequences, i.e:
TypeError: can only concatenate class1 (not "class2") to class1
or should another one be used like "Unsupported operand type(s) for op: 'class1' and 'class2'?
The first is problematic with cases like `+=` where an iterable is accepted, the second seems better to me at least.
As for `operator.concat`, any reason why the check is made beforehand to see if the first argument has a `__getitem__` method? Couldn't that just be removed allowing the exception from `concat(1, '')` to just propagate to the caller?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29116>
_______________________________________
More information about the Python-bugs-list
mailing list