New submission from Adam Cmiel <acmi...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue40911>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to