summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-09-01 23:06:35 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-09-01 23:06:35 (GMT)
commitb44c8619fed78642ff5bd786f3a0b4427ea3a10a (patch)
tree5b9dbb4e313ef16343d73df706052bf2efb55440
parent71b2ded05e55a044cbba9257ed43ed34b5e9648c (diff)
downloadcpython-b44c8619fed78642ff5bd786f3a0b4427ea3a10a.zip
cpython-b44c8619fed78642ff5bd786f3a0b4427ea3a10a.tar.gz
cpython-b44c8619fed78642ff5bd786f3a0b4427ea3a10a.tar.bz2
document that various functions that parse from source will interpret things as latin-1 (closes #18870)
-rw-r--r--Doc/library/ast.rst8
-rw-r--r--Doc/library/functions.rst12
-rw-r--r--Doc/reference/simple_stmts.rst19
3 files changed, 21 insertions, 18 deletions
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 5130d00..4db4060 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -131,10 +131,10 @@ and classes for traversing abstract syntax trees:
.. function:: literal_eval(node_or_string)
- 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, numbers, tuples, lists, dicts, booleans,
- and ``None``.
+ Safely evaluate an expression node or a Unicode or *Latin-1* encoded string
+ containing a Python expression. The string or node provided may only consist
+ of the following Python literal structures: strings, numbers, tuples, lists,
+ dicts, 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.
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 08fb7fe..d40452a 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -199,8 +199,10 @@ available. They are listed here in alphabetical order.
Compile the *source* into a code or AST object. Code objects can be executed
by an :keyword:`exec` statement or evaluated by a call to :func:`eval`.
- *source* can either be a string or an AST object. Refer to the :mod:`ast`
- module documentation for information on how to work with AST objects.
+ *source* can either be a Unicode string, a *Latin-1* encoded string or an
+ AST object.
+ Refer to the :mod:`ast` module documentation for information on how to work
+ with AST objects.
The *filename* argument should give the file from which the code was read;
pass some recognizable value if it wasn't read from a file (``'<string>'`` is
@@ -388,9 +390,9 @@ available. They are listed here in alphabetical order.
.. function:: eval(expression[, globals[, locals]])
- The arguments are a string and optional globals and locals. If provided,
- *globals* must be a dictionary. If provided, *locals* can be any mapping
- object.
+ The arguments are a Unicode or *Latin-1* encoded string and optional
+ globals and locals. If provided, *globals* must be a dictionary.
+ If provided, *locals* can be any mapping object.
.. versionchanged:: 2.4
formerly *locals* was required to be a dictionary.
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index a6fd064..254d1ba 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -981,15 +981,16 @@ The :keyword:`exec` statement
exec_stmt: "exec" `or_expr` ["in" `expression` ["," `expression`]]
This statement supports dynamic execution of Python code. The first expression
-should evaluate to either a string, an open file object, a code object, or a
-tuple. If it is a string, the string is parsed as a suite of Python statements
-which is then executed (unless a syntax error occurs). [#]_ If it is an open
-file, the file is parsed until EOF and executed. If it is a code object, it is
-simply executed. For the interpretation of a tuple, see below. In all cases,
-the code that's executed is expected to be valid as file input (see section
-:ref:`file-input`). Be aware that the :keyword:`return` and :keyword:`yield`
-statements may not be used outside of function definitions even within the
-context of code passed to the :keyword:`exec` statement.
+should evaluate to either a Unicode string, a *Latin-1* encoded string, an open
+file object, a code object, or a tuple. If it is a string, the string is parsed
+as a suite of Python statements which is then executed (unless a syntax error
+occurs). [#]_ If it is an open file, the file is parsed until EOF and executed.
+If it is a code object, it is simply executed. For the interpretation of a
+tuple, see below. In all cases, the code that's executed is expected to be
+valid as file input (see section :ref:`file-input`). Be aware that the
+:keyword:`return` and :keyword:`yield` statements may not be used outside of
+function definitions even within the context of code passed to the
+:keyword:`exec` statement.
In all cases, if the optional parts are omitted, the code is executed in the
current scope. If only the first expression after ``in`` is specified,