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 Behdad.Esfahbod
Recipients Behdad.Esfahbod
Date 2014-09-30.14:57:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412089039.94.0.626035759284.issue22525@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation says:

"""
Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None.

This can be used for safely evaluating strings containing Python expressions from untrusted sources without the need to parse the values oneself.
"""

This makes me to believe that this is a useful replacement for eval() that is safe.  However, it fails to make it clear that it parses **one literal**, NOT an expression.  Ie. it can't handle "2*2".  Weirdly enough, at least with my Python 3.2.3, it does handle "2+2" with no problem.

This seriously limits the usefulness of this function.  Is there really no equivalent that parses simple expressions of literals?
History
Date User Action Args
2014-09-30 14:57:19Behdad.Esfahbodsetrecipients: + Behdad.Esfahbod
2014-09-30 14:57:19Behdad.Esfahbodsetmessageid: <1412089039.94.0.626035759284.issue22525@psf.upfronthosting.co.za>
2014-09-30 14:57:19Behdad.Esfahbodlinkissue22525 messages
2014-09-30 14:57:19Behdad.Esfahbodcreate