[Python-checkins] cpython: Make test_builtin work when executed directly

brett.cannon python-checkins at python.org
Sun Jun 16 05:24:19 CEST 2013


http://hg.python.org/cpython/rev/5b90da280515
changeset:   84163:5b90da280515
user:        Brett Cannon <brett at python.org>
date:        Sat Jun 15 23:24:11 2013 -0400
summary:
  Make test_builtin work when executed directly

files:
  Lib/test/test_builtin.py |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -584,7 +584,10 @@
                 raise frozendict_error("frozendict is readonly")
 
         # read-only builtins
-        frozen_builtins = frozendict(__builtins__)
+        if isinstance(__builtins__, types.ModuleType):
+            frozen_builtins = frozendict(__builtins__.__dict__)
+        else:
+            frozen_builtins = frozendict(__builtins__)
         code = compile("__builtins__['superglobal']=2; print(superglobal)", "test", "exec")
         self.assertRaises(frozendict_error,
                           exec, code, {'__builtins__': frozen_builtins})

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


More information about the Python-checkins mailing list