Changeset

6416:9af742bb45b2

prosody: Fix getfenv replacement for Lua 5.2
author Kim Alvefur <zash@zash.se>
date Wed, 17 Sep 2014 14:50:00 +0200
parents 6415:010b141e91ed
children 6417:060b63a27e9b
files prosody
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);