Issue 33879: Item assignment in tuple mutates list despite throwing error

Issue33879

Created on 2018-06-16 15:13 by njayinthehouse, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg319748 - (view) Author: (njayinthehouse) Date: 2018-06-16 15:13
Seems like a bug.

    >>> a = (1, [1])
    >>> a[1] += [2]
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'tuple' object does not support item assignment
    >>> a
    (1, [1, 2])
msg319762 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-06-16 17:00
Interesting. I googled this and came across this note which covers this : https://docs.python.org/2/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78060
2018-06-16 21:04:11r.david.murraysetstatus: open -> closed
resolution: not a bug
stage: resolved
2018-06-16 17:00:05xtreaksetnosy: + xtreak
messages: + msg319762
2018-06-16 15:13:15njayinthehousecreate