mirror of
https://github.com/minetest/minetest.git
synced 2024-11-15 12:13:45 +01:00
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
|
||||
|
||||
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)
|
||||
if not func then return nil, err end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user