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

Side by Side Diff: Doc/library/ast.rst

Issue 15452: Improve the security model for logging listener()
Patch Set: Created 7 years, 5 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « no previous file | Lib/ast.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`ast` --- Abstract Syntax Trees 1 :mod:`ast` --- Abstract Syntax Trees
2 ==================================== 2 ====================================
3 3
4 .. module:: ast 4 .. module:: ast
5 :synopsis: Abstract Syntax Tree classes and manipulation. 5 :synopsis: Abstract Syntax Tree classes and manipulation.
6 6
7 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de> 7 .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de>
8 .. sectionauthor:: Georg Brandl <georg@python.org> 8 .. sectionauthor:: Georg Brandl <georg@python.org>
9 9
10 **Source code:** :source:`Lib/ast.py` 10 **Source code:** :source:`Lib/ast.py`
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 expression. The string or node provided may only consist of the following 119 expression. The string or node provided may only consist of the following
120 Python literal structures: strings, bytes, numbers, tuples, lists, dicts, 120 Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
121 sets, booleans, and ``None``. 121 sets, booleans, and ``None``.
122 122
123 This can be used for safely evaluating strings containing Python expressions 123 This can be used for safely evaluating strings containing Python expressions
124 from untrusted sources without the need to parse the values oneself. 124 from untrusted sources without the need to parse the values oneself.
125 125
126 .. versionchanged:: 3.2 126 .. versionchanged:: 3.2
127 Now allows bytes and set literals. 127 Now allows bytes and set literals.
128 128
129 .. function:: lookup_eval(node_or_string, context, allow_imports=False)
130
131 Safely evaluate an expression node or a string containing a Python expression .
132 In addition to the literals supported by :func:`literal_eval`, ``lookup_eval` `
133 supports the following features:
134
135 * The use of names, which are looked up in a mapping, ``context``. In
136 addition, the names ``True``, ``False`` and ``None`` are supported. If
137 ``allow_imports`` is ``True`` and a name is not found in ``context``, an
138 attempt will be made to import it and use the imported module as the
139 result.
140
141 * The use of the following sub-expression types:
142
143 * Array indexing and slicing
144 * Attribute access
145 * Arithmetic operators: ``+``, ``-``, ``*``, ``/``, ``//``, ``%``, ``**``
146 * Bitwise operators: ``&``, ````|, ``^`` ``<<``, ``>>``
147 * Relational operators: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``
148 * Membership: ``in``, ``not in``
149 * Logic: ``and``, ``or``
150 * Unary operators: ``+``, ``-``, ``~``, ``not``
151
152 On any error (e.g. a syntax error), a :class:`ValueError` is raised.
153
154 .. versionadded:: 3.4
129 155
130 .. function:: get_docstring(node, clean=True) 156 .. function:: get_docstring(node, clean=True)
131 157
132 Return the docstring of the given *node* (which must be a 158 Return the docstring of the given *node* (which must be a
133 :class:`FunctionDef`, :class:`ClassDef` or :class:`Module` node), or ``None`` 159 :class:`FunctionDef`, :class:`ClassDef` or :class:`Module` node), or ``None``
134 if it has no docstring. If *clean* is true, clean up the docstring's 160 if it has no docstring. If *clean* is true, clean up the docstring's
135 indentation with :func:`inspect.cleandoc`. 161 indentation with :func:`inspect.cleandoc`.
136 162
137 163
138 .. function:: fix_missing_locations(node) 164 .. function:: fix_missing_locations(node)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 266
241 267
242 .. function:: dump(node, annotate_fields=True, include_attributes=False) 268 .. function:: dump(node, annotate_fields=True, include_attributes=False)
243 269
244 Return a formatted dump of the tree in *node*. This is mainly useful for 270 Return a formatted dump of the tree in *node*. This is mainly useful for
245 debugging purposes. The returned string will show the names and the values 271 debugging purposes. The returned string will show the names and the values
246 for fields. This makes the code impossible to evaluate, so if evaluation is 272 for fields. This makes the code impossible to evaluate, so if evaluation is
247 wanted *annotate_fields* must be set to False. Attributes such as line 273 wanted *annotate_fields* must be set to False. Attributes such as line
248 numbers and column offsets are not dumped by default. If this is wanted, 274 numbers and column offsets are not dumped by default. If this is wanted,
249 *include_attributes* can be set to ``True``. 275 *include_attributes* can be set to ``True``.
OLDNEW
« 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+