[Python-checkins] r69413 - python/trunk/Lib/test/test_compiler.py

neil.schemenauer python-checkins at python.org
Sat Feb 7 19:35:16 CET 2009


Author: neil.schemenauer
Date: Sat Feb  7 19:35:16 2009
New Revision: 69413

Log:
Add test for issue #999042, explict global statement works.


Modified:
   python/trunk/Lib/test/test_compiler.py

Modified: python/trunk/Lib/test/test_compiler.py
==============================================================================
--- python/trunk/Lib/test/test_compiler.py	(original)
+++ python/trunk/Lib/test/test_compiler.py	Sat Feb  7 19:35:16 2009
@@ -165,6 +165,13 @@
         exec c in dct
         self.assertEquals(dct.get('result'), 1)
 
+    def testGlobal(self):
+        code = compiler.compile('global x\nx=1', '<string>', 'exec')
+        d1 = {'__builtins__': {}}
+        d2 = {}
+        exec code in d1, d2
+        # x should be in the globals dict
+        self.assertEquals(d1.get('x'), 1)
 
     def testPrintFunction(self):
         c = compiler.compile('from __future__ import print_function\n'


More information about the Python-checkins mailing list