From 58dcbb2b5e414bd1eeb6c25bf3fc2ee81a9a261f Mon Sep 17 00:00:00 2001 From: Binary Date: Sat, 17 Sep 2016 18:55:08 +0200 Subject: [PATCH] don't use an additional flag to see if we updated the lua state and need to bring it back, just use NULL in case we did not --- lupa/_lupa.pyx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lupa/_lupa.pyx b/lupa/_lupa.pyx index 17467f7a..0ed2bae7 100644 --- a/lupa/_lupa.pyx +++ b/lupa/_lupa.pyx @@ -1399,13 +1399,11 @@ cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) excep cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: cdef LuaRuntime runtime = None - cdef lua_State* stored_state - updated_state = False + cdef lua_State* stored_state = NULL try: runtime = py_obj.runtime if runtime._state is not L: - updated_state = True stored_state = runtime._state runtime._state = L return call_python(runtime, L, py_obj) @@ -1413,7 +1411,7 @@ cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: try: runtime.store_raised_exception() finally: return -1 finally: - if updated_state: + if stored_state is not NULL: runtime._state = stored_state cdef int py_object_call(lua_State* L) nogil: