[pypy-commit] pypy translation-cleanup: Use Constants instead of pypy.interpreter Modules.

rlamy noreply at buildbot.pypy.org
Thu Aug 30 18:38:40 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57018:c65684d5b666
Date: 2012-08-24 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/c65684d5b666/

Log:	Use Constants instead of pypy.interpreter Modules.

	sys and __builtin__ can simply be represented by Constants in flow
	space. There is no need to use the complex Module class from the
	PyPy interpreter.

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
@@ -5,7 +5,6 @@
 import types
 from pypy.tool import error
 from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
-from pypy.interpreter.module import Module
 from pypy.interpreter.error import OperationError
 from pypy.interpreter import pyframe, argument
 from pypy.objspace.flow.model import *
@@ -52,13 +51,8 @@
     def initialize(self):
         self.concrete_mode = 1
         self.w_None     = Constant(None)
-        self.builtin    = Module(self, Constant('__builtin__'),
-                                 Constant(__builtin__.__dict__))
-        def pick_builtin(w_globals):
-            return self.builtin
-        self.builtin.pick_builtin = pick_builtin
-        self.sys        = Module(self, Constant('sys'), Constant(sys.__dict__))
-        self.sys.recursionlimit = 100
+        self.builtin = Constant(__builtin__)
+        self.sys = Constant(sys)
         self.w_False    = Constant(False)
         self.w_True     = Constant(True)
         self.w_type     = Constant(type)
@@ -489,8 +483,8 @@
         except KeyError:
             # not in the globals, now look in the built-ins
             try:
-                value = self.unwrap(self.builtin.w_dict)[varname]
-            except KeyError:
+                value = getattr(self.unwrap(self.builtin), varname)
+            except AttributeError:
                 message = "global name '%s' is not defined" % varname
                 raise OperationError(self.w_NameError, self.wrap(message))
         return self.wrap(value)


More information about the pypy-commit mailing list