From 4f4170205a2bfa7e7facaaae27515f178003cf54 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Wed, 12 Apr 2023 20:31:59 +0800 Subject: [PATCH] Fix error in `test_decrease_memory` for Lua 5.1.5 Don't run Lua code after decreasing memory limit. Lua 5.1 seems can't free the memory of the `a` variable after deleting it, thus it will raise `LuaMemoryError` again. And the memory limiting feature doesn't support Lua 5.1. --- lupa/tests/test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lupa/tests/test.py b/lupa/tests/test.py index 1ce505ae..8b6acd21 100644 --- a/lupa/tests/test.py +++ b/lupa/tests/test.py @@ -3034,7 +3034,9 @@ def test_decrease_memory(self): self.assertGreaterEqual(self.lua.get_memory_used(), 50000) self.assertRaises(self.lupa.LuaMemoryError, self.lua.eval, "('b'):rep(10)") del self.lua.globals()["a"] - self.lua.eval("('b'):rep(10)") + if self.lua.lua_version >= (5, 2): + # Lua 5.1 doesn't free the memory of `a` after deleting it + self.lua.eval("('b'):rep(10)") def test_compile_not_enough_memory(self): self.lua.set_max_memory(10)