Skip to content

lua.table keyword arguments are misleading when runtime encoding is None #66

Open
@kmike

Description

@kmike

When runtime encoding is None, lua.table(foo=132) creates a Lua table with userdata as a key. There is a workaround (use lua.table_from which supports dicts with binary keys). But I think it makes more sense to use Lua strings for keys for tables created by lua.table, even if the encoding is None. I expect this to work even if encoding is None:

from lupa import LuaRuntime
lua = LuaRuntime(encoding=None)
tbl = lua.table(x=1)

# this should print 1, but it prints 'nil'
lua.eval("function(tbl) print(type(tbl.x)) end")(tbl) 

# this prints
# userdata  number
lua.eval("function(tbl) for k,v in pairs(tbl) do print(type(k),type(v)) end end")(tbl)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions