<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FgetUnprotectedMetatable</id>
	<title>Module:table/getUnprotectedMetatable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FgetUnprotectedMetatable"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;action=history"/>
	<updated>2026-04-15T21:56:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=474925&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=474925&amp;oldid=prev"/>
		<updated>2025-11-04T17:47:20Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:47, 4 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=459874&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local _getmetatable = debug.getmetatable  -- For testing (and just in case it gets enabled).  if _getmetatable ~= nil then 	-- Avoid debug.getmetatable() throwing an error if 0 arguments are passed, 	-- for parity with the other function. 	return function(t) 		return _getmetatable(t) 	end end  _getmetatable = getmetatable local pcall = pcall local rawget = rawget local setmetatable = setmetatable local type = type  --[==[ Attempts to retrieve the input value&#039;s metatable,...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=459874&amp;oldid=prev"/>
		<updated>2025-06-28T09:14:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local _getmetatable = debug.getmetatable  -- For testing (and just in case it gets enabled).  if _getmetatable ~= nil then 	-- Avoid debug.getmetatable() throwing an error if 0 arguments are passed, 	-- for parity with the other function. 	return function(t) 		return _getmetatable(t) 	end end  _getmetatable = getmetatable local pcall = pcall local rawget = rawget local setmetatable = setmetatable local type = type  --[==[ Attempts to retrieve the input value&amp;#039;s metatable,...&amp;quot;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:14, 28 June 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=474924&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho at 00:23, 23 May 2025</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/getUnprotectedMetatable&amp;diff=474924&amp;oldid=prev"/>
		<updated>2025-05-23T00:23:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local _getmetatable = debug.getmetatable&lt;br /&gt;
&lt;br /&gt;
-- For testing (and just in case it gets enabled). &lt;br /&gt;
if _getmetatable ~= nil then&lt;br /&gt;
	-- Avoid debug.getmetatable() throwing an error if 0 arguments are passed,&lt;br /&gt;
	-- for parity with the other function.&lt;br /&gt;
	return function(t)&lt;br /&gt;
		return _getmetatable(t)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
_getmetatable = getmetatable&lt;br /&gt;
local pcall = pcall&lt;br /&gt;
local rawget = rawget&lt;br /&gt;
local setmetatable = setmetatable&lt;br /&gt;
local type = type&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Attempts to retrieve the input value&amp;#039;s metatable, and returns it if found. If the value does not have a metatable, returns {nil}. If the input value does have a metatable, but that metatable is not possible to retrieve because it is protected with the `__metatable` metamethod, returns {false}.&lt;br /&gt;
&lt;br /&gt;
This is a useful way to ensure that functions can reliably distinguish between objects that do not have metamethods, objects with known metamethods, and objects with unknown metamethods.]==]&lt;br /&gt;
return function(t)&lt;br /&gt;
	local mt = _getmetatable(t)&lt;br /&gt;
	-- If `mt` is nil, there&amp;#039;s no metatable.&lt;br /&gt;
	if mt == nil then&lt;br /&gt;
		return nil&lt;br /&gt;
	-- If `mt` is not a table, the real metatable is protected and there&amp;#039;s no&lt;br /&gt;
	-- way of retrieving it.&lt;br /&gt;
	elseif type(mt) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	-- Try setting `mt` as the metatable with `setmetatable`; if the metatable&lt;br /&gt;
	-- is protected, this will cause an error to be thrown (revealing it as&lt;br /&gt;
	-- protected), and if it isn&amp;#039;t, then `mt` must be the real metatable anyway,&lt;br /&gt;
	-- so nothing has changed. Also make a special exception for data loaded via&lt;br /&gt;
	-- mw.loadData(), which sets each metatable at its own __metatable key as a&lt;br /&gt;
	-- way to stop the use of setmetatable() without actually hiding it. This is&lt;br /&gt;
	-- spoofable, but low-risk.&lt;br /&gt;
	return (pcall(setmetatable, t, mt) or rawget(mt, &amp;quot;mw_loadData&amp;quot;) == true) and mt or false&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
</feed>