[Python-checkins] cpython: Use compile() instead of eval().

martin.v.loewis python-checkins at python.org
Wed Sep 28 09:22:19 CEST 2011


http://hg.python.org/cpython/rev/636444a2827e
changeset:   72479:636444a2827e
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Wed Sep 28 09:22:13 2011 +0200
summary:
  Use compile() instead of eval().

files:
  Lib/test/test_sys.py |  10 ++++------
  1 files changed, 4 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -856,12 +856,10 @@
         # verify that the UTF-8 size is accounted for
         s = chr(0x4000)   # 4 bytes canonical representation
         check(s, size(compactfields) + 4)
-        try:
-            # eval() will trigger the generation of the UTF-8 representation
-            # as a side effect
-            eval(s)
-        except NameError:
-            check(s, size(compactfields) + 4 + 4)
+        # compile() will trigger the generation of the UTF-8
+        # representation as a side effect
+        compile(s, "<stdin>", "eval")
+        check(s, size(compactfields) + 4 + 4)
         # TODO: add check that forces the presence of wchar_t representation
         # TODO: add check that forces layout of unicodefields
         # weakref

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


More information about the Python-checkins mailing list