Skip to content

Commit

Permalink
Safer handling of the Lua stack (GH-188)
Browse files Browse the repository at this point in the history
Some places don't lock the LuaRuntime before fiddling with the Lua stack, and many places don't ensure extra slots either.
This PR also involves other changes:

*  Add preconditions and postconditions to important functions/methods
*  Change behaviour _LuaObject.__str__
   *   If __tostring doesn't exist, use _LuaObject.__repr__
   *   If __tostring returns non-string value, raise a TypeError
   *   If __tostring raises an error, raise a LuaError
*  lua_pushglobaltable instead of pushing _G, which may not point to the global table.
*  Make lock_runtime return boolean and not raise error directly
*  Use LUA_NOREF and LUA_REFNIL constants for effective handling of Lua references
*  Add important assertions (checks if LuaRuntime._state is not NULL, and if _LuaObject._runtime is None, etc...)
  • Loading branch information
guidanoli authored Jul 22, 2021
1 parent dff2487 commit 7fe8768
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 161 deletions.
Loading

0 comments on commit 7fe8768

Please sign in to comment.