# HG changeset patch # User Kim Alvefur # Date 1410958200 -7200 # Node ID 9af742bb45b27103f0c9074c54a10b2935bb3476 # Parent 010b141e91ed9d411e692f321cc3e56d1cf9e5c1 prosody: Fix getfenv replacement for Lua 5.2 diff -r 010b141e91ed -r 9af742bb45b2 prosody --- a/prosody Wed Sep 17 14:48:49 2014 +0200 +++ b/prosody Wed Sep 17 14:50:00 2014 +0200 @@ -153,7 +153,12 @@ local _real_require = require; if not getfenv then -- FIXME: This is a hack to replace getfenv() in Lua 5.2 - function getfenv(f) return debug.getupvalue(debug.getinfo(f or 1).func, 1); end + function getfenv(f) + local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1); + if name == "_ENV" then + return env; + end + end end function require(...) local curr_env = getfenv(2);