It is widely known that using eval() is a potential security risk so the use of ast.literal_eval(node_or_string) is promoted
However In python 2.7 it returns ValueError: malformed string when running this example:
>>> ast.literal_eval("4 + 9")
Whereas in python 3.3 this example works as expected:
>>> ast.literal_eval('4+9')
13
Why does it run on python 3 and not python 2? How can I fix it in python 2.7 without using the risky eval() function?