[issue32893] ast.literal_eval() shouldn't accept booleans as numbers in AST
Serhiy Storchaka
report at bugs.python.org
Wed Feb 21 13:30:09 EST 2018
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
This doesn't look like Python literal. And if the function accepts a one particular non-literal the user can except that it accepts other looking similarly non-literal, that is false.
Actually ast.literal_eval("+True") is error. But ast.literal_eval(ast.UnaryOp(ast.UAdd(), ast.Constant(True))) is successful by oversight.
And look at this from other side. What is the benefit of accepting "+True"? This doesn't make the code simpler.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32893>
_______________________________________
More information about the Python-bugs-list
mailing list