[pypy-svn] r10835 - pypy/dist/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Mon Apr 18 23:27:59 CEST 2005


Author: arigo
Date: Mon Apr 18 23:27:58 2005
New Revision: 10835

Modified:
   pypy/dist/pypy/interpreter/nestedscope.py
Log:
Safety check and hint for the annotator: cell variables must be Cell
instances.


Modified: pypy/dist/pypy/interpreter/nestedscope.py
==============================================================================
--- pypy/dist/pypy/interpreter/nestedscope.py	(original)
+++ pypy/dist/pypy/interpreter/nestedscope.py	Mon Apr 18 23:27:58 2005
@@ -1,6 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.pyopcode import PyInterpFrame
-from pypy.interpreter import function, pycode
+from pypy.interpreter import function, pycode, pyframe
 from pypy.interpreter.baseobjspace import Wrappable
 
 class Cell(Wrappable):
@@ -167,7 +167,12 @@
         codeobj = f.space.interpclass_w(w_codeobj)
         assert isinstance(codeobj, pycode.PyCode)
         nfreevars = len(codeobj.co_freevars)
-        freevars = [f.space.interpclass_w(f.valuestack.pop()) for i in range(nfreevars)]
+        freevars = []
+        for i in range(nfreevars):
+            cell = f.space.interpclass_w(f.valuestack.pop())
+            if not isinstance(cell, Cell):
+                raise pyframe.BytecodeCorruption
+            freevars.append(cell)
         freevars.reverse()
         defaultarguments = [f.valuestack.pop() for i in range(numdefaults)]
         defaultarguments.reverse()



More information about the Pypy-commit mailing list