[Python-checkins] cpython (3.2): #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py.

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


http://hg.python.org/cpython/rev/2fa338374719
changeset: 80325:2fa338374719
branch: 3.2
parent: 80321:bb39ca6bcd7a
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Nov 09 11:46:19 2012 +0100
summary:
 #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py. Patch by Serhiy Storchaka.
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
@@ -682,6 +682,12 @@
 
 - Issue #14018: Fix OS X Tcl/Tk framework checking when using OS X SDKs.
 
+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

AltStyle によって変換されたページ (->オリジナル) /