Lua `require` function will now display errors properly

This commit is contained in:
Gnome Ann 2022-01-21 00:56:25 -05:00
parent d209c2f7ac
commit 44d49ed0b2
1 changed files with 6 additions and 1 deletions

View File

@ -1614,7 +1614,12 @@ return function(_python, _bridged)
error("module '" .. modname .. "' not found:" .. table.concat(errors))
return
end
local retval = old_loadfile(path, "t", env)()
local f, err = old_loadfile(path, "t", env)
if err ~= nil then
error(err)
return
end
local retval = (f())
package_loaded[env][modname] = retval == nil or retval
return package_loaded[env][modname], path
end