prosody
changeset 6419 9af742bb45b2
parent 6067 dab7ad6fa23c
child 6473 67501b5576d3
--- 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);