]> granicus.if.org Git - python/commitdiff
Add test for issue #999042, explict global statement works.
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>
Sat, 7 Feb 2009 18:35:16 +0000 (18:35 +0000)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>
Sat, 7 Feb 2009 18:35:16 +0000 (18:35 +0000)
Lib/test/test_compiler.py

index c7ec50fe51a667882d27bb906011a35810b25af3..052e07e8ffd657ebc5a25f222337248280b1a1c4 100644 (file)
@@ -165,6 +165,13 @@ class CompilerTest(unittest.TestCase):
         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'