[New-bugs-announce] [issue40264] List item inside tuple seemingly allows for item assignment even after throwing error

Rahul B report at bugs.python.org
Sun Apr 12 15:41:29 EDT 2020


New submission from Rahul B <rahul.bishain at gmail.com>:

Even though item assignment throws error, the list inside tuple 'a' gets modified in place. Refer below, where the list value [8] gets added to the list value [5,6,7,7] at a[3]

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

----------
messages: 366264
nosy: Rahul B
priority: normal
severity: normal
status: open
title: List item inside tuple seemingly allows for item assignment even after throwing error
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40264>
_______________________________________


More information about the New-bugs-announce mailing list