[Python-checkins] r82804 - in python/branches/py3k: Doc/library/ast.rst Lib/ast.py Misc/NEWS

georg.brandl python-checkins at python.org
Sun Jul 11 11:41:21 CEST 2010


Author: georg.brandl
Date: Sun Jul 11 11:41:21 2010
New Revision: 82804

Log:
Allow set literals in literal_eval().

Modified:
   python/branches/py3k/Doc/library/ast.rst
   python/branches/py3k/Lib/ast.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/ast.rst
==============================================================================
--- python/branches/py3k/Doc/library/ast.rst	(original)
+++ python/branches/py3k/Doc/library/ast.rst	Sun Jul 11 11:41:21 2010
@@ -119,12 +119,15 @@
 
    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``.
+   Python literal structures: strings, 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.
 
+   .. versionchanged:: 3.2
+      Now allows set literals.
+
 
 .. function:: get_docstring(node, clean=True)
 

Modified: python/branches/py3k/Lib/ast.py
==============================================================================
--- python/branches/py3k/Lib/ast.py	(original)
+++ python/branches/py3k/Lib/ast.py	Sun Jul 11 11:41:21 2010
@@ -58,6 +58,8 @@
             return tuple(map(_convert, node.elts))
         elif isinstance(node, List):
             return list(map(_convert, node.elts))
+        elif isinstance(node, Set):
+            return set(map(_convert, node.elts))
         elif isinstance(node, Dict):
             return dict((_convert(k), _convert(v)) for k, v
                         in zip(node.keys, node.values))

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Jul 11 11:41:21 2010
@@ -470,7 +470,9 @@
 Library
 -------
 
-- Issue #9164: Ensure that sysconfig handles duplicate -arch flags in CFLAGS
+- ``ast.literal_eval()`` now allows set literals.
+
+- Issue #9164: Ensure that sysconfig handles duplicate -arch flags in CFLAGS.
 
 - Issue #7646: The fnmatch pattern cache no longer grows without bound.
 


More information about the Python-checkins mailing list