# ----- GIL acquisition
acquire_gil = self.need_gil_acquisition(lenv)
if acquire_gil:
- env.use_utility_code(py23_init_threads_utility_code)
+ env.use_utility_code(force_init_threads_utility_code)
code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
# ----- Automatic lead-ins for certain special functions
if not lenv.nogil:
finally_clause = GILExitNode(pos, state = state))
def analyse_expressions(self, env):
- env.use_utility_code(py23_init_threads_utility_code)
+ env.use_utility_code(force_init_threads_utility_code)
was_nogil = env.nogil
env.nogil = 1
TryFinallyStatNode.analyse_expressions(self, env)
pass
def generate_execution_code(self, code):
- code.putln("/*with %s:*/ {" % self.state)
+ code.mark_pos(self.pos)
if self.state == 'gil':
- code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
+ code.putln("{ PyGILState_STATE _save = PyGILState_Ensure();")
else:
- code.putln("PyThreadState *_save;")
+ code.putln("{ PyThreadState *_save;")
code.putln("Py_UNBLOCK_THREADS")
TryFinallyStatNode.generate_execution_code(self, code)
code.putln("}")
#------------------------------------------------------------------------------------
-py23_init_threads_utility_code = UtilityCode(
+force_init_threads_utility_code = UtilityCode(
proto="""
#ifndef __PYX_FORCE_INIT_THREADS
#if PY_VERSION_HEX < 0x02040200