[issue4907] ast.literal_eval does not properly handled complex numbers
Armin Ronacher
report at bugs.python.org
Sat Jan 10 16:45:02 CET 2009
New submission from Armin Ronacher <armin.ronacher at active-4.com>:
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 <report at bugs.python.org>
<http://bugs.python.org/issue4907>
_______________________________________
More information about the Python-bugs-list
mailing list