[pypy-commit] pypy py3.3: Merged in marky1991/pypy_new/py3.3 (pull request #396)
mjacob
pypy.commits at gmail.com
Fri Feb 12 21:30:58 EST 2016
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.3
Changeset: r82200:32dbf468ae33
Date: 2016-02-13 03:30 +0100
http://bitbucket.org/pypy/pypy/changeset/32dbf468ae33/
Log: Merged in marky1991/pypy_new/py3.3 (pull request #396)
Fix test_reimport_builtin in py3.3
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,23 @@
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')
-
+ # 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
+ # requiring that the entire dict already be loaded. To support that
+ # 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):
+ new_items = self.w_dict.iteritems()
+ while True:
+ w_key, w_value = new_items.next_item()
+ if w_key is None:
+ break
+ if not self.space.is_true(self.space.contains(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 """
@@ -90,6 +105,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
More information about the pypy-commit
mailing list