This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aronacher
Recipients aronacher
Date 2009-01-10.15:45:00
SpamBayes Score 0.028499166
Marked as misclassified No
Message-id <1231602302.94.0.22786815912.issue4907@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-01-10 15:45:03aronachersetrecipients: + aronacher
2009-01-10 15:45:02aronachersetmessageid: <1231602302.94.0.22786815912.issue4907@psf.upfronthosting.co.za>
2009-01-10 15:45:01aronacherlinkissue4907 messages
2009-01-10 15:45:01aronachercreate