From: Stefan Behnel Date: Wed, 18 Dec 2013 19:50:54 +0000 (+0100) Subject: fix try-finally-return in functions returning void X-Git-Tag: 0.20b1~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc136a211ba251561b27a1303d3d8488320cffb8;p=platform%2Fupstream%2Fpython-cython.git fix try-finally-return in functions returning void --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 6b4faf5..d90ba78 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -6328,6 +6328,7 @@ class TryFinallyStatNode(StatNode): # handle exception case, in addition to return/break/continue handle_error_case = True + func_return_type = None disallow_continue_in_try_finally = 0 # There doesn't seem to be any point in disallowing @@ -6349,6 +6350,8 @@ class TryFinallyStatNode(StatNode): self.body = self.body.analyse_expressions(env) self.finally_clause = self.finally_clause.analyse_expressions(env) self.func_return_type = env.return_type + if self.func_return_type and self.func_return_type.is_void: + self.func_return_type = None return self nogil_check = Node.gil_error @@ -6462,8 +6465,6 @@ class TryFinallyStatNode(StatNode): if old_label == return_label and not self.finally_clause.is_terminator: # store away return value for later reuse if self.func_return_type: - # pure safety check, func_return_type should - # always be set when return label is used ret_temp = code.funcstate.allocate_temp( self.func_return_type, manage_ref=False) code.putln("%s = %s;" % (ret_temp, Naming.retval_cname))