Author: Manuel Jacob <[email protected]>
Branch: py3.3
Changeset: r82606:e0e2bb1b3050
Date: 2016-02-29 00:46 +0100
http://bitbucket.org/pypy/pypy/changeset/e0e2bb1b3050/

Log:    Merged in marky1991/pypy_new/fix_magic_reload (pull request #405)

        3.3: Fix_magic_reload

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -57,7 +57,7 @@
             if not self.lazy and self.w_initialdict is None:
                 self.save_module_content_for_future_reload()
 
-    def save_module_content_for_future_reload(self):
+    def save_module_content_for_future_reload(self, save_all=False):
         # Because setdictvalue is unable to immediately load all attributes
         # (due to an importlib bootstrapping problem), this method needs to be
         # able to support saving the content of a module's dict without
@@ -65,14 +65,14 @@
         # properly, when updating the dict, we must be careful to never
         # overwrite the value of a key already in w_initialdict. (So as to 
avoid
         # overriding the builtin value with a user-provided value)
-        if not self.space.is_none(self.w_initialdict):
+        if self.space.is_none(self.w_initialdict) or save_all:
+            self.w_initialdict = self.space.call_method(self.w_dict, 'copy')
+        else:
             w_items = self.space.call_method(self.w_dict, 'items')
             for w_item in self.space.iteriterable(w_items):
                 w_key, w_value = self.space.fixedview(w_item, 
expected_length=2)
                 if not self.space.contains_w(self.w_initialdict, w_key):
                     self.space.setitem(self.w_initialdict, w_key, w_value)
-        else:
-            self.w_initialdict = self.space.call_method(self.w_dict, 'copy')
 
     def get_applevel_name(cls):
         """ NOT_RPYTHON """
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -130,7 +130,7 @@
 
 @unwrap_spec(w_module=MixedModule)
 def save_module_content_for_future_reload(space, w_module):
-    w_module.save_module_content_for_future_reload()
+    w_module.save_module_content_for_future_reload(save_all=True)
 
 def set_code_callback(space, w_callable):
     cache = space.fromcache(CodeHookCache)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to