You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to pass a python dictionary as an argument into a function defined in LUA code but it crashes without exception.
The Lua function returns the first non-empty parameter, or nil if they are all empty.
LUA code: lua/Article.lua
localArticle= { }
functionvalidTextArg( args, name, ... )
localtexte=args[name]
iftype( texte ) =='string' andtexte~='' thenreturntexteelseif#{ ... } >0thenreturnvalidTextArg( args, ... )
endendfunctionArticle.article( args )
-- validArg returns the first non-empty parameter, or nil if they are all empty.-- Only parameter names should be passed to the function.localvalidArg=function ( ... ) returnvalidTextArg( args, ... ) orfalseendreturnvalidArg( 'périodique', 'revue', 'journal' )
endreturnArticle
Python code: main.py
importlupa.lua54aslupalua=lupa.LuaRuntime(
unpack_returned_tuples=True,
register_eval=False,
)
print(
f"Using {lupa.LuaRuntime().lua_implementation} (compiled with {lupa.LUA_VERSION})"
)
lua.execute(""" local Article = require('lua/Article') function Tpl_Article(args) return Article.article(args) end """params= {
'revue': 'Revue des langues romanes',
'numéro': '105',
'année': '2001',
'pages': '503-517',
}
lua_result=lua.globals().Tpl_Article(params) # Crash
How do I invoke the LUA script and pass dictionary arguments ?
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to pass a python dictionary as an argument into a function defined in LUA code but it crashes without exception.
The Lua function returns the first non-empty parameter, or nil if they are all empty.
LUA code: lua/Article.lua
Python code: main.py
How do I invoke the LUA script and pass dictionary arguments ?
The text was updated successfully, but these errors were encountered: