[pypy-svn] pypy getdict-signature: getdict() now takes the 'space' as argument

amauryfa commits-noreply at bitbucket.org
Fri Mar 11 14:43:00 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: getdict-signature
Changeset: r42512:93ae975476a6
Date: 2011-03-11 14:26 +0100
http://bitbucket.org/pypy/pypy/changeset/93ae975476a6/

Log:	getdict() now takes the 'space' as argument

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -176,9 +176,9 @@
             i += 1
         return new_frame.run()
 
-    def getdict(self):
+    def getdict(self, space):
         if self.w_func_dict is None:
-            self.w_func_dict = self.space.newdict(instance=True)
+            self.w_func_dict = space.newdict(instance=True)
         return self.w_func_dict
 
     def setdict(self, space, w_dict):

diff --git a/pypy/interpreter/interactive.py b/pypy/interpreter/interactive.py
--- a/pypy/interpreter/interactive.py
+++ b/pypy/interpreter/interactive.py
@@ -27,7 +27,8 @@
         import keyword
         w_res = self.space.call_method(self.w_globals, "keys")
         namespace_keys = self.space.unwrap(w_res)
-        w_res = self.space.call_method(self.space.builtin.getdict(), "keys")
+        w_res = self.space.call_method(self.space.builtin.getdict(self.space),
+                                       "keys")
         builtin_keys = self.space.unwrap(w_res)
 
         matches = []

diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -261,7 +261,7 @@
         if "user_setup" in body:
             base_user_setup = body["user_setup"]
         class Proto(object):
-            def getdict(self):
+            def getdict(self, space):
                 return self.w__dict__
             
             def setdict(self, space, w_dict):
@@ -566,7 +566,7 @@
 from pypy.interpreter.special import NotImplemented, Ellipsis
 
 def descr_get_dict(space, w_obj):
-    w_dict = w_obj.getdict()
+    w_dict = w_obj.getdict(space)
     if w_dict is None:
         typename = space.type(w_obj).getname(space)
         raise operationerrfmt(space.w_TypeError,

diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -58,7 +58,7 @@
         sys.exitfunc(), if the module has been imported.
         """
 
-    def getdict(self):
+    def getdict(self, space):
         return self.w_dict
 
     def descr_module__new__(space, w_subtype, __args__):
@@ -87,8 +87,9 @@
             w_mod    = space.getbuiltinmodule('_pickle_support')
             mod      = space.interp_w(MixedModule, w_mod)
             new_inst = mod.get('module_new')
-            return space.newtuple([new_inst, space.newtuple([w_name,
-                                    self.getdict()]),
+            return space.newtuple([new_inst,
+                                   space.newtuple([w_name,
+                                                   self.getdict(space)]),
                                   ])
         #already imported case
         w_import = space.builtin.get('__import__')

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -28,24 +28,24 @@
     _settled_ = True
     user_overridden_class = False
 
-    def getdict(self):
+    def getdict(self, space):
         return None
 
     def getdictvalue(self, space, attr):
-        w_dict = self.getdict()
+        w_dict = self.getdict(space)
         if w_dict is not None:
             return space.finditem_str(w_dict, attr)
         return None
 
     def setdictvalue(self, space, attr, w_value):
-        w_dict = self.getdict()
+        w_dict = self.getdict(space)
         if w_dict is not None:
             space.setitem_str(w_dict, attr, w_value)
             return True
         return False
 
     def deldictvalue(self, space, w_name):
-        w_dict = self.getdict()
+        w_dict = self.getdict(space)
         if w_dict is not None:
             try:
                 space.delitem(w_dict, w_name)
@@ -510,7 +510,7 @@
 
     def export_builtin_exceptions(self):
         """NOT_RPYTHON"""
-        w_dic = self.exceptions_module.getdict()
+        w_dic = self.exceptions_module.getdict(self)
         w_keys = self.call_method(w_dic, "keys")
         exc_types_w = {}
         for w_name in self.unpackiterable(w_keys):

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -115,9 +115,8 @@
             return w_value
 
 
-    def getdict(self):
+    def getdict(self, space):
         if self.lazy:
-            space = self.space
             for name in self.loaders:
                 w_value = self.get(name)
                 space.setitem(self.w_dict, space.new_interned_str(name), w_value)
@@ -126,7 +125,7 @@
         return self.w_dict
 
     def _freeze_(self):
-        self.getdict()
+        self.getdict(self.space)
         self.w_initialdict = None
         self.startup_called = False
         self._frozen = True

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -584,7 +584,7 @@
         return pytraceback.offset2lineno(self.pycode, self.last_instr)
 
     def fget_f_builtins(self, space):
-        return self.get_builtin().getdict()
+        return self.get_builtin().getdict(space)
 
     def fget_f_back(self, space):
         return self.space.wrap(self.f_backref())


More information about the Pypy-commit mailing list