[New-bugs-announce] [issue11562] += on list inside a tuple raises TypeError but succeds anyway

Mike Smith report at bugs.python.org
Tue Mar 15 23:20:49 CET 2011


New submission from Mike Smith <scgtrp+python-bugs at gmail.com>:

Using += to append to a list inside a tuple raises a TypeError but succeeds in appending the value anyway:

>>> t = (1, [2, 3, 4])
>>> t[1].append(5)
>>> t[1] += [6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> t
(1, [2, 3, 4, 5, 6])

I have reproduced this on all the Python interpreters available to me (CPython 2.6, 2.7, and 3.1).

----------
components: Interpreter Core
messages: 131055
nosy: scgtrp
priority: normal
severity: normal
status: open
title: += on list inside a tuple raises TypeError but succeds anyway
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1

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


More information about the New-bugs-announce mailing list