[pypy-commit] pypy py3.3: If the module is already in sys.modules, it must be a reload, so just initialize the existing module instance and return it. (Fixes test_reload_builtin)

marky1991 pypy.commits at gmail.com
Wed Feb 24 04:06:49 EST 2016


Author: Mark Young <marky1991 at gmail.com>
Branch: py3.3
Changeset: r82469:afa0092349e3
Date: 2016-02-13 10:12 -0500
http://bitbucket.org/pypy/pypy/changeset/afa0092349e3/

Log:	If the module is already in sys.modules, it must be a reload, so
	just initialize the existing module instance and return it. (Fixes
	test_reload_builtin)

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,8 @@
         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, reuse=False)
+    reuse = space.finditem(space.sys.get('modules'), w_name) is not None
+    return space.getbuiltinmodule(name, force_init=True, reuse=reuse)
 
 def init_frozen(space, w_name):
     return None


More information about the pypy-commit mailing list