Message349148
This isn't a bug.
In Python 2, True and False are variable names rather than keywords. That means they can be shadowed:
>>> False = 10
>>> True = 20
>>> [False, True]
[10, 20]
A Counter() is a kind a dictionary that returns zero rather than raising a KeyError. When you give eval() a Counter as a locals() dict, you're effectively shadowing the False and True variables:
>>> eval('[False, True]', {}, Counter())
[0, 0]
That follows from:
>>> c = Counter()
>>> c['True']
0
>>> c['False']
0
So effectively, your example translates to:
>>> [0, 0, 0].count(0)
3 |
|
Date |
User |
Action |
Args |
2019-08-07 03:18:03 | rhettinger | set | recipients:
+ rhettinger, xuancong84 |
2019-08-07 03:18:03 | rhettinger | set | messageid: <1565147883.56.0.606976608476.issue37780@roundup.psfhosted.org> |
2019-08-07 03:18:03 | rhettinger | link | issue37780 messages |
2019-08-07 03:18:02 | rhettinger | create | |
|