# HG changeset patch # User Matthew Wild # Date 1335559065 -3600 # Node ID 7c81b04a4fed31a5b798a57e05e4b267dd49e140 # Parent 5ebf4096a2e17d4ef4a19adc66baf33b92c225e4 modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda) diff -r 5ebf4096a2e1 -r 7c81b04a4fed core/modulemanager.lua --- a/core/modulemanager.lua Fri Apr 27 20:01:21 2012 +0100 +++ b/core/modulemanager.lua Fri Apr 27 21:37:45 2012 +0100 @@ -142,10 +142,10 @@ },{ __index = modulemap["*"][module_name].module; }); + local host_module = setmetatable({ module = host_module_api }, { __index = mod }); + host_module_api.environment = host_module; local ok, result, module_err = call_module_method(mod, "add_host", host_module_api); if not ok or result == false then return nil, ok and module_err or result; end - local host_module = setmetatable({ module = host_module_api }, { __index = mod }); - host_module.module.environment = host_module; modulemap[host][module_name] = host_module; return host_module; end