![](https://secure.gravatar.com/avatar/e1e9ff4ee829216477cef0a92cd488c3.jpg?s=120&d=mm&r=g)
(Sending an email instead of just asking in irc so I don't keep spamming the question) In the 3.3 branch, there is this failing test: http://buildbot.pypy.org/summary/longrepr?testname=AppTestMagic.%28%29.test_save_module_content_for_future_reload&builder=own-linux-x86-64&build=4372&mod=module.__pypy__.test.test_magic I made this change to make it not fail: https://bitbucket.org/marky1991/pypy/commits/afb2b3cd9535399043722f3d822762e... The call chain is thus (mostly pseudocode here): (test code) reload(module) lib-python/3/imp.py, in reload loader.load_module(module.name) lib-python/3/importlib/_bootstrap.py, in load_module init_builtin(module.name) pypy/module/imp/interp_imp.py, in init_builtin space.getbuiltinmodule(module.name) pypy/interpreter/baseobjspace.py sys.modules.get(module.name) The last method in that chain, space.getbuiltinmodule, has a parameter force_init, which defaults to False. If you pass it as true, we avoid the (rpython equivalent to) sys.modules.get(module_name) code, getting the module object and successfully calling init() on it. (The failing test needs reload() to invoke module.init()) In the commit pasted above, I changed init_builtin to call space.getbuiltinmodule with force_init=True. This fixes reload, but I would think that this would be wrong for nonreload scenarios. (I've checked the py3k branch, which has this test (which passes locally), and it passes force_init=True if the finder's modtype is C_BUILTIN) However, I don't see a good way to conditionalize the passing of force_init. Does anyone have any suggestions as to how to handle this issue? (Given what I've found in py3k's code, is my change actually a valid fix?) If anyone has time to reply, feel free to just ping me in irc if I'm on. Thanks
![](https://secure.gravatar.com/avatar/5b37e6b4ac97453e4ba9dba37954cf79.jpg?s=120&d=mm&r=g)
Hi Marky, No clue why, but your e-mail written 3 days ago only shows up now on the mailing list... If you didn't get any answer on IRC in the meantime: that test is about this line: __pypy__.save_module_content_for_future_reload(sys) The test is failing because that line didn't have any effect. A bientôt, Armin.
![](https://secure.gravatar.com/avatar/5b37e6b4ac97453e4ba9dba37954cf79.jpg?s=120&d=mm&r=g)
Hi Marky, On Tue, Jan 5, 2016 at 9:56 AM, Armin Rigo <arigo@tunes.org> wrote:
__pypy__.save_module_content_for_future_reload(sys)
The test is failing because that line didn't have any effect.
Maybe I'm wrong, and the exact cause is more subtle. In general, you should first understand why it works in "default" and what is the difference in py3.3. In "default" I see that the function imp.init_builtin() calls space.getbuiltinmodule(name) without the force_init argument too, so the difference is somewhere else... Probably closer to wherever "reload()" is implemented? A bientôt, Armin.
participants (2)
-
Armin Rigo
-
marky1991 .