This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, xuancong84
Date 2019-08-07.03:18:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565147883.56.0.606976608476.issue37780@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-08-07 03:18:03rhettingersetrecipients: + rhettinger, xuancong84
2019-08-07 03:18:03rhettingersetmessageid: <1565147883.56.0.606976608476.issue37780@roundup.psfhosted.org>
2019-08-07 03:18:03rhettingerlinkissue37780 messages
2019-08-07 03:18:02rhettingercreate