prosody
changeset 6473 67501b5576d3
parent 6419 9af742bb45b2
child 6557 6c22bec3e8d0
--- a/prosody	Wed Oct 08 18:42:33 2014 -0400
+++ b/prosody	Mon Oct 13 21:02:04 2014 +0200
@@ -151,13 +151,11 @@
 	-- for neat sandboxing of modules
 	local _realG = _G;
 	local _real_require = require;
-	if not getfenv then
+	local getfenv = getfenv or function (f)
 		-- FIXME: This is a hack to replace getfenv() in Lua 5.2
-		function getfenv(f)
-			local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1);
-			if name == "_ENV" then
-				return env;
-			end
+		local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1);
+		if name == "_ENV" then
+			return env;
 		end
 	end
 	function require(...)