New submission from Armin Ronacher <[email protected]>:
ast.literal_eval does not properly handle complex numbers:
>>> ast.literal_eval("1j")
1j
>>> ast.literal_eval("2+1j")
Traceback (most recent call last):
...
ValueError: malformed string
>>> ast.literal_eval("(2+1j)")
Traceback (most recent call last):
...
ValueError: malformed string
Expected result:
>>> ast.literal_eval("1j")
1j
>>> ast.literal_eval("2+1j")
(2+1j)
>>> ast.literal_eval("(2+1j)")
(2+1j)
I attached a patch that fixes this problem.
----------
components: Library (Lib)
files: literal-eval.patch
keywords: needs review, patch, patch
messages: 79548
nosy: aronacher
priority: normal
severity: normal
stage: patch review
status: open
title: ast.literal_eval does not properly handled complex numbers
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file12674/literal-eval.patch
_______________________________________
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