[Python-checkins] cpython (2.7): document that various functions that parse from source will interpret things as

benjamin.peterson python-checkins at python.org
Mon Sep 2 01:07:00 CEST 2013


http://hg.python.org/cpython/rev/869cbcabb934
changeset:   85498:869cbcabb934
branch:      2.7
parent:      85484:869d50357a71
user:        Benjamin Peterson <benjamin at python.org>
date:        Sun Sep 01 19:06:35 2013 -0400
summary:
  document that various functions that parse from source will interpret things as latin-1 (closes #18870)

files:
  Doc/library/ast.rst            |   8 ++++----
  Doc/library/functions.rst      |  12 +++++++-----
  Doc/reference/simple_stmts.rst |  19 ++++++++++---------
  3 files changed, 21 insertions(+), 18 deletions(-)


diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -131,10 +131,10 @@
 
 .. 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
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -199,8 +199,10 @@
 
    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 @@
 
 .. 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
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -981,15 +981,16 @@
    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,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list