[New-bugs-announce] [issue43021] Unpacking tuple argument in combination with inline if statement
Wietse Jacobs
report at bugs.python.org
Mon Jan 25 03:42:55 EST 2021
New submission from Wietse Jacobs <wietse.j at gmail.com>:
I suspect that I found a bug. If I run the following script:
```
def f(t=None):
t0, t1 = t if t is not None else [], []
return t0, t1
def g(t=None):
if t is None:
t = [], []
t0, t1 = t
return t0, t1
def test():
res_f = f(t=([1, 1], [2, 2]))
res_g = g(t=([1, 1], [2, 2]))
assert res_f == res_g, f'{res_f=} != {res_g=}'
test()
```
I get an assertion error, with:
```
res_f=(([1, 1], [2, 2]), []) != res_g=([1, 1], [2, 2])
```
I expected them to be equal.
----------
messages: 385607
nosy: wietse.j
priority: normal
severity: normal
status: open
title: Unpacking tuple argument in combination with inline if statement
type: behavior
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43021>
_______________________________________
More information about the New-bugs-announce
mailing list