[issue4907] ast.literal_eval does not properly handled complex numbers

Armin Ronacher report at bugs.python.org
Tue Jan 13 12:34:53 CET 2009


Armin Ronacher <armin.ronacher at active-4.com> added the comment:

literal_eval has eval() semantics and not complex() constructor
semantics.  It accepts what eval() accepts just without arithmetic and
unsafe features.

For exmaple "(2 + 4j)" is perfectly fine even though the complex call
only supports "2+4j" (no parentheses and whitespace).

I commit the fix with the ValueError except Georg suggested.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4907>
_______________________________________


More information about the Python-bugs-list mailing list