Mark Dickinson <[email protected]> added the comment:
Nice fix!
Exactly which complex strings should be accepted here?
The patched version of literal-eval still accepts some
things that would be rejected as inputs to complex():
>>> ast.literal_eval('-1+-3j')
(-1-3j)
>>> complex('-1+-3j')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: complex() arg is a malformed string
and it produces different results from the complex
constructor in some other cases:
>>> complex('-0.0+0.0j').real
-0.0
>>> ast.literal_eval('-0.0+0.0j').real
0.0
But since I don't really know what ast_literal
is used for, I don't know whether this matters.
It still seems odd to me to be doing just one
special case of expression evaluation in
ast_literal, but maybe that's just me.
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue4907>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com