[New-bugs-announce] [issue40911] Unexpected behaviour for += assignment to list inside tuple
Adam Cmiel
report at bugs.python.org
Mon Jun 8 10:58:25 EDT 2020
New submission from Adam Cmiel <acmiel1 at gmail.com>:
Python version:
Python 3.8.3 (default, May 15 2020, 00:00:00)
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Description:
When assigning to a tuple index using +=, if the element at that index is a list, the list is extended and a TypeError is raised.
a = ([],)
try:
a[0] += [1]
except TypeError:
assert a != ([1],) # assertion fails
else:
assert a == ([1],)
The expected behaviour is that only one of those things would happen (probably the list being extended with no error, given that a[0].extend([1]) works fine).
----------
components: Interpreter Core
messages: 370990
nosy: Adam Cmiel
priority: normal
severity: normal
status: open
title: Unexpected behaviour for += assignment to list inside tuple
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40911>
_______________________________________
More information about the New-bugs-announce
mailing list