[Python-checkins] cpython (merge 3.3 -> default): #13301: merge with 3.3.

ezio.melotti python-checkins at python.org
Fri Nov 9 11:52:20 CET 2012


http://hg.python.org/cpython/rev/aa02f7be68f6
changeset:   80327:aa02f7be68f6
parent:      80323:d170844a363f
parent:      80326:ea2cb9b69fd9
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Fri Nov 09 11:51:30 2012 +0100
summary:
  #13301: merge with 3.3.

files:
  Misc/NEWS            |  6 ++++++
  Tools/i18n/msgfmt.py |  6 +++---
  2 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -316,6 +316,12 @@
 - Issue #15819: Make sure we can build Python out-of-tree from a read-only
   source directory.  (Somewhat related to issue #9860.)
 
+Tools/Demos
+-----------
+
+- Issue #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py
+  Patch by Serhiy Storchaka.
+
 Documentation
 -------------
 
diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py
--- a/Tools/i18n/msgfmt.py
+++ b/Tools/i18n/msgfmt.py
@@ -24,8 +24,9 @@
         Display version information and exit.
 """
 
+import os
 import sys
-import os
+import ast
 import getopt
 import struct
 import array
@@ -180,8 +181,7 @@
         l = l.strip()
         if not l:
             continue
-        # XXX: Does this always follow Python escape semantics?
-        l = eval(l)
+        l = ast.literal_eval(l)
         if section == ID:
             msgid += l.encode(encoding)
         elif section == STR:

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


More information about the Python-checkins mailing list