Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r61035:60b3f3d002ba
Date: 2013-02-10 12:49 +0200
http://bitbucket.org/pypy/pypy/changeset/60b3f3d002ba/
Log: Convert w_globals passed to exec to celldict, if not already a
celldict. Potentially questionable checkin, but I don't think it's
too bad
diff --git a/pypy/interpreter/eval.py b/pypy/interpreter/eval.py
--- a/pypy/interpreter/eval.py
+++ b/pypy/interpreter/eval.py
@@ -28,6 +28,7 @@
def exec_code(self, space, w_globals, w_locals):
"Implements the 'exec' statement."
# this should be on PyCode?
+ space.possibly_convert_to_celldict(w_globals)
frame = space.createframe(self, w_globals, None)
frame.setdictscope(w_locals)
return frame.run()
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -109,6 +109,18 @@
def view_as_kwargs(self):
return self.strategy.view_as_kwargs(self)
+ def convert_to_celldict_strategy(self, space):
+ from pypy.objspace.std.celldict import ModuleDictStrategy
+
+ if isinstance(self.strategy, ModuleDictStrategy):
+ return
+ items_w = self.items()
+ self.strategy = ModuleDictStrategy(space)
+ self.dstorage = self.strategy.get_empty_storage()
+ for w_tup in items_w:
+ w_key, w_val = space.fixedview(w_tup, 2)
+ self.setitem(w_key, w_val)
+
def _add_indirections():
dict_methods = "setitem setitem_str getitem \
getitem_str delitem length \
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -684,3 +684,10 @@
if not hasattr(self, "_interplevel_classes"):
return None # before running initialize
return self._interplevel_classes.get(w_type, None)
+
+ def possibly_convert_to_celldict(self, w_dict):
+ """ Converts the dict to celldict, if it's a dict, otherwise
+ leaves it alone
+ """
+ if isinstance(w_dict, W_DictMultiObject):
+ w_dict.convert_to_celldict_strategy(self)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit