Commit 08077345 authored by Stefan Behnel's avatar Stefan Behnel

reduce scope of gil state declaration in try-finally

parent b5d83dee
...@@ -6442,9 +6442,6 @@ class TryFinallyStatNode(StatNode): ...@@ -6442,9 +6442,6 @@ class TryFinallyStatNode(StatNode):
preserve_error = self.preserve_exception and code.label_used(new_error_label) preserve_error = self.preserve_exception and code.label_used(new_error_label)
needs_success_cleanup = not self.finally_clause.is_terminator needs_success_cleanup = not self.finally_clause.is_terminator
if preserve_error:
if self.is_try_finally_in_nogil:
code.declare_gilstate()
if not self.body.is_terminator: if not self.body.is_terminator:
code.putln('/*normal exit:*/{') code.putln('/*normal exit:*/{')
...@@ -6455,6 +6452,8 @@ class TryFinallyStatNode(StatNode): ...@@ -6455,6 +6452,8 @@ class TryFinallyStatNode(StatNode):
if preserve_error: if preserve_error:
code.putln('/*exception exit:*/{') code.putln('/*exception exit:*/{')
if self.is_try_finally_in_nogil:
code.declare_gilstate()
if needs_success_cleanup: if needs_success_cleanup:
exc_lineno_cnames = tuple([ exc_lineno_cnames = tuple([
code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment