[New-bugs-announce] [issue37780] A strange bug in eval() not present in Python 3

wang xuancong report at bugs.python.org
Tue Aug 6 21:43:58 EDT 2019


New submission from wang xuancong <xuancong84 at gmail.com>:

We all know that since:
[False, True, False].count(True) gives 1
eval('[False, True, False].count(True)') also gives 1.

However, in Python 2,
eval('[False, True, False].count(True)', {}, Counter()) gives 3, while
eval('[False, True, False].count(True)', {}, {}) gives 1.
Take note that a Counter is a special kind of defaultdict, which is again a special kind of dict. Thus, this should not alter the behaviour of eval().

This behaviour is correct in Python 3.

----------
components: Library (Lib)
messages: 349146
nosy: xuancong84
priority: normal
severity: normal
status: open
title: A strange bug in eval() not present in Python 3
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37780>
_______________________________________


More information about the New-bugs-announce mailing list