Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Unified Diff: Doc/library/ast.rst

Issue 15452: Improve the security model for logging listener()
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/ast.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/ast.rst Thu Oct 11 00:11:26 2012 -0700
+++ b/Doc/library/ast.rst Thu Oct 11 16:47:49 2012 +0100
@@ -126,6 +126,32 @@
.. versionchanged:: 3.2
Now allows bytes and set literals.
+.. function:: lookup_eval(node_or_string, context, allow_imports=False)
+
+ Safely evaluate an expression node or a string containing a Python expression.
+ In addition to the literals supported by :func:`literal_eval`, ``lookup_eval``
+ supports the following features:
+
+ * The use of names, which are looked up in a mapping, ``context``. In
+ addition, the names ``True``, ``False`` and ``None`` are supported. If
+ ``allow_imports`` is ``True`` and a name is not found in ``context``, an
+ attempt will be made to import it and use the imported module as the
+ result.
+
+ * The use of the following sub-expression types:
+
+ * Array indexing and slicing
+ * Attribute access
+ * Arithmetic operators: ``+``, ``-``, ``*``, ``/``, ``//``, ``%``, ``**``
+ * Bitwise operators: ``&``, ````|, ``^`` ``<<``, ``>>``
+ * Relational operators: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``
+ * Membership: ``in``, ``not in``
+ * Logic: ``and``, ``or``
+ * Unary operators: ``+``, ``-``, ``~``, ``not``
+
+ On any error (e.g. a syntax error), a :class:`ValueError` is raised.
+
+ .. versionadded:: 3.4
.. function:: get_docstring(node, clean=True)
« no previous file with comments | « no previous file | Lib/ast.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+