[pypy-svn] r75729 - in pypy/branch/fast-forward/pypy/interpreter: . test

benjamin at codespeak.net benjamin at codespeak.net
Thu Jul 1 19:29:23 CEST 2010


Author: benjamin
Date: Thu Jul  1 19:29:22 2010
New Revision: 75729

Modified:
   pypy/branch/fast-forward/pypy/interpreter/nestedscope.py
   pypy/branch/fast-forward/pypy/interpreter/test/test_nestedscope.py
Log:
fix one of my stupider mistakes; don't mutate co_cellvars, ever

Modified: pypy/branch/fast-forward/pypy/interpreter/nestedscope.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/nestedscope.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/nestedscope.py	Thu Jul  1 19:29:22 2010
@@ -123,7 +123,7 @@
         super_fast2locals(self)
         # cellvars are values exported to inner scopes
         # freevars are values coming from outer scopes 
-        freevarnames = self.pycode.co_cellvars
+        freevarnames = list(self.pycode.co_cellvars)
         if self.pycode.co_flags & consts.CO_OPTIMIZED:
             freevarnames.extend(self.pycode.co_freevars)
         for i in range(len(freevarnames)):

Modified: pypy/branch/fast-forward/pypy/interpreter/test/test_nestedscope.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/test/test_nestedscope.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/test/test_nestedscope.py	Thu Jul  1 19:29:22 2010
@@ -89,3 +89,14 @@
                 locals()
             return X
         assert f(1).x == 12
+
+    def test_nested_scope_locals_mutating_cellvars(self):
+        def f():
+            x = 12
+            def m():
+                locals()
+                x
+                locals()
+                return x
+            return m
+        assert f()() == 12



More information about the Pypy-commit mailing list