Skip to content
Browse files

Print stack traceback support for Lua 5.1

Lua 5.1 lacks the C API luaL_traceback() function, so Lua
debug.traceback() has to be used instead.
  • Loading branch information...
1 parent d7966db commit 568e414754a22c36d7f5ff1403c931aa193f90bf Lefteris Chatzimparmpas committed
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/lua.c
View
8 src/lua.c
@@ -98,7 +98,15 @@ static int
traceback_handler(lua_State *lua)
{
+#if LUA_VERSION_NUM < 502
+ lua_getfield(lua, LUA_GLOBALSINDEX, "debug");
+ lua_getfield(lua, -1, "traceback");
+ lua_pushvalue(lua, 1);
+ lua_pushinteger(lua, 2);
+ lua_call(lua, 2, 1);
+#else
luaL_traceback(lua, lua, lua_tostring(lua, 1), 0);
+#endif
return 1;
}

0 comments on commit 568e414

Please sign in to comment.
Something went wrong with that request. Please try again.