Message357112
This code snippet exposes a small edge case in lib2to3, where syntactically invalid code is generated:
data = [1, 2, 3, 4, 5]
x = filter(lambda x: True if x > 2 else False, data)
print(x)
lib2to3 transforms 2nd line above to:
x = [x for x in data if True if x > 2 else False]
which is invalid (would be OK with parentheses after 1st 'if')
Admittedly, the original code here is more complex that it should be ('True if foo else False' being equivalent to just 'foo'), but walked into this in "the real world" and wanted to report it. |
|
Date |
User |
Action |
Args |
2019-11-20 23:12:36 | Zoran Simic | set | recipients:
+ Zoran Simic |
2019-11-20 23:12:36 | Zoran Simic | set | messageid: <1574291556.7.0.332589714744.issue38871@roundup.psfhosted.org> |
2019-11-20 23:12:36 | Zoran Simic | link | issue38871 messages |
2019-11-20 23:12:36 | Zoran Simic | create | |
|