Author: Mark Young <marky1...@gmail.com>
Branch: py3.3
Changeset: r82196:38a9de4803aa
Date: 2016-02-11 23:48 -0500
http://bitbucket.org/pypy/pypy/changeset/38a9de4803aa/

Log:    Fix test_reimport_builtin again.

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -58,8 +58,17 @@
                 self.save_module_content_for_future_reload()
 
     def save_module_content_for_future_reload(self):
-        self.w_initialdict = self.space.call_method(self.w_dict, 'copy')
-
+        if not self.space.is_none(self.w_initialdict):
+            present_keys = self.w_initialdict.w_keys()
+            new_keys = self.w_dict.w_keys()
+            key_count = new_keys.length()
+            for i in range(key_count):
+                key = new_keys.getitem(i)
+                val_to_set = self.space.getitem(self.w_dict, key)
+                if not self.space.is_true(self.space.contains(present_keys, 
key)):
+                    self.space.setitem(self.w_initialdict, key, val_to_set)
+        else:
+            self.w_initialdict = self.space.call_method(self.w_dict, 'copy')
 
     def get_applevel_name(cls):
         """ NOT_RPYTHON """
@@ -90,6 +99,7 @@
     def setdictvalue(self, space, attr, w_value):
         if self.lazy:
             self._load_lazily(space, attr)
+            self.save_module_content_for_future_reload()
         space.setitem_str(self.w_dict, attr, w_value)
         return True
 
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -86,7 +86,7 @@
         return
     # force_init is needed to make reload actually reload instead of just
     # using the already-present module in sys.modules.
-    return space.getbuiltinmodule(name, force_init=True)
+    return space.getbuiltinmodule(name, force_init=True, reuse=False)
 
 def init_frozen(space, w_name):
     return None
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to