From 080773450fa6cef887d81ba8a50d4c12840b3415 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 31 Dec 2013 12:27:06 +0100 Subject: [PATCH] reduce scope of gil state declaration in try-finally --- Cython/Compiler/Nodes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 60ae1bb..1d934e8 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -6442,9 +6442,6 @@ class TryFinallyStatNode(StatNode): preserve_error = self.preserve_exception and code.label_used(new_error_label) 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: code.putln('/*normal exit:*/{') @@ -6455,6 +6452,8 @@ class TryFinallyStatNode(StatNode): if preserve_error: code.putln('/*exception exit:*/{') + if self.is_try_finally_in_nogil: + code.declare_gilstate() if needs_success_cleanup: exc_lineno_cnames = tuple([ code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False) -- 2.7.4