diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2006-08-04 16:20:30 +0000 |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2006-08-04 16:20:30 +0000 |
commit | 06ded09d4048bf44ce9b61c82494cf0a0825412c (patch) | |
tree | 5aa766517b8a84d0d4d048dcd3c62f78638da8e0 /Lib/test/test_compiler.py | |
parent | 45381938e940279df3962f6ebe01efb8375198a3 (diff) | |
download | cpython-git-06ded09d4048bf44ce9b61c82494cf0a0825412c.tar.gz |
Fix the 'compiler' package to generate correct code for MAKE_CLOSURE.
In the 2.5 development cycle, MAKE_CLOSURE as changed to take free
variables as a tuple rather than as individual items on the stack.
Closes patch #1534084.
Diffstat (limited to 'Lib/test/test_compiler.py')
-rw-r--r-- | Lib/test/test_compiler.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index 929a12bb6f..9dff71e299 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -104,6 +104,19 @@ class CompilerTest(unittest.TestCase): self.assertEquals(flatten([1, [2]]), [1, 2]) self.assertEquals(flatten((1, (2,))), [1, 2]) + def testNestedScope(self): + c = compiler.compile('def g():\n' + ' a = 1\n' + ' def f(): return a + 2\n' + ' return f()\n' + 'result = g()', + '<string>', + 'exec') + dct = {} + exec c in dct + self.assertEquals(dct.get('result'), 3) + + NOLINENO = (compiler.ast.Module, compiler.ast.Stmt, compiler.ast.Discard) ############################################################################### |