[New-bugs-announce] [issue12654] sum() works with bytes objects

Antoine Pitrou report at bugs.python.org
Fri Jul 29 14:45:31 CEST 2011


New submission from Antoine Pitrou <pitrou at free.fr>:

... while it apparently shouldn't:

>>> sum([b'', b''], b'')
b''
>>> sum([b'', b''], bytearray())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sum() can't sum bytes [use b''.join(seq) instead]


In 2.7, the situation is the reverse:

>>> sum([b'', b''], b'')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sum() can't sum strings [use ''.join(seq) instead]
>>> sum([b'', b''], bytearray())
bytearray(b'')

----------
components: Interpreter Core
messages: 141363
nosy: mark.dickinson, pitrou, rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: sum() works with bytes objects
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

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


More information about the New-bugs-announce mailing list