[pypy-commit] pypy translation-cleanup: Kill FlowEC.w_globals

rlamy noreply at buildbot.pypy.org
Fri Aug 10 10:03:33 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r56680:0a90d88e3ecd
Date: 2012-08-09 18:40 +0100
http://bitbucket.org/pypy/pypy/changeset/0a90d88e3ecd/

Log:	Kill FlowEC.w_globals

	FlowExecutionContext doesn't really need this attribute, but the
	frame does, so store it there only.

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -213,11 +213,9 @@
         self.is_generator = bool(code.co_flags & CO_GENERATOR)
         self.code = code
 
-        self.w_globals = space.wrap(func.func_globals)
-
         self.crnt_offset = -1
         self.frame = frame = FlowSpaceFrame(self.space, code,
-                               self.w_globals, func, constargs)
+                               func, constargs)
         self.joinpoints = {}
         initialblock = SpamBlock(frame.getstate())
         self.pendingblocks = collections.deque([initialblock])
@@ -385,7 +383,8 @@
 
 class FlowSpaceFrame(pyframe.CPythonFrame):
 
-    def __init__(self, space, code, w_globals, func, constargs=None):
+    def __init__(self, space, code, func, constargs=None):
+        w_globals = Constant(func.func_globals)
         class outerfunc: pass # hack
         if func.func_closure is not None:
             cl = [c.cell_contents for c in func.func_closure]
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -363,7 +363,7 @@
     def setitem(self, w_obj, w_key, w_val):
         # protect us from globals write access
         ec = self.getexecutioncontext()
-        if ec and w_obj is ec.w_globals:
+        if ec and w_obj is ec.frame.w_globals:
             raise SyntaxError("attempt to modify global attribute %r in %r"
                             % (w_key, ec.graph.func))
         if self.concrete_mode:
diff --git a/pypy/objspace/flow/test/test_framestate.py b/pypy/objspace/flow/test/test_framestate.py
--- a/pypy/objspace/flow/test/test_framestate.py
+++ b/pypy/objspace/flow/test/test_framestate.py
@@ -17,8 +17,7 @@
             pass
         code = func.func_code
         code = PyCode._from_code(self.space, code)
-        w_globals = Constant({}) # space.newdict()
-        frame = FlowSpaceFrame(space, code, w_globals, func)
+        frame = FlowSpaceFrame(space, code, func)
         # hack the frame
         frame.locals_stack_w[frame.pycode.co_nlocals-1] = Constant(None)
         return frame


More information about the pypy-commit mailing list