#!/usr/bin/python3

import ctypes

f='liblua5.4.so'
l=ctypes.CDLL(f)
l.lua_tolstring.restype = ctypes.c_char_p
s = ctypes.c_void_p(l.luaL_newstate())
l.luaL_openlibs(s)
script = b'return package.loaded'
l.luaL_loadbufferx(s, script, len(script), b'test', None)
l.lua_pcallk(s, 0, -1, None, 0, None)
l.lua_pushnil(s)
while l.lua_next(s, -2) != 0:
	print(l.lua_type(s, -2), l.lua_type(s, -1), l.lua_tolstring(s, -2, None))
	l.lua_settop(s, -2)

