forked from Mirrorlandia_minetest/minetest
Deserialization: Restore backwards compat (#12519)
This commit is contained in:
parent
6df69f9b5b
commit
ac4eb746fe
@ -188,6 +188,16 @@ local function dummy_func() end
|
|||||||
local nan = (0/0)^1 -- +nan
|
local nan = (0/0)^1 -- +nan
|
||||||
|
|
||||||
function core.deserialize(str, safe)
|
function core.deserialize(str, safe)
|
||||||
|
-- Backwards compatibility
|
||||||
|
if str == nil then
|
||||||
|
core.log("deprecated", "minetest.deserialize called with nil (expected string).")
|
||||||
|
return nil, "Invalid type: Expected a string, got nil"
|
||||||
|
end
|
||||||
|
local t = type(str)
|
||||||
|
if t ~= "string" then
|
||||||
|
error(("minetest.deserialize called with %s (expected string)."):format(t))
|
||||||
|
end
|
||||||
|
|
||||||
local func, err = loadstring(str)
|
local func, err = loadstring(str)
|
||||||
if not func then return nil, err end
|
if not func then return nil, err end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user