From: Stefan Behnel Date: Mon, 9 Aug 2010 17:40:41 +0000 (+0200) Subject: fix temp handling inside of EvalWithTempExprNode: X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=35f59b76d7581988a018beeb808084aedae738e0;p=cython.git fix temp handling inside of EvalWithTempExprNode: temp_expression must free its temps as early as possible --- diff --git a/Cython/Compiler/UtilNodes.py b/Cython/Compiler/UtilNodes.py index 228ff129..d96db1d9 100644 --- a/Cython/Compiler/UtilNodes.py +++ b/Cython/Compiler/UtilNodes.py @@ -186,8 +186,8 @@ class LetNodeMixin: def setup_temp_expr(self, code): self.temp_expression.generate_evaluation_code(code) - self._result_in_temp = self.temp_expression.result_in_temp() self.temp_type = self.temp_expression.type + self._result_in_temp = self.temp_expression.result_in_temp() if self._result_in_temp: self.temp = self.temp_expression.result() else: @@ -195,10 +195,15 @@ class LetNodeMixin: self.temp = code.funcstate.allocate_temp( self.temp_type, manage_ref=True) code.putln("%s = %s;" % (self.temp, self.temp_expression.result())) + self.temp_expression.generate_disposal_code(code) + self.temp_expression.free_temps(code) self.lazy_temp.result_code = self.temp def teardown_temp_expr(self, code): - if not self._result_in_temp: + if self._result_in_temp: + self.temp_expression.generate_disposal_code(code) + self.temp_expression.free_temps(code) + else: if self.temp_type.is_pyobject: code.put_decref_clear(self.temp, self.temp_type) code.funcstate.release_temp(self.temp) @@ -227,6 +232,12 @@ class EvalWithTempExprNode(ExprNodes.ExprNode, LetNodeMixin): self.subexpression.analyse_types(env) self.type = self.subexpression.type + def free_subexpr_temps(self, code): + self.subexpression.free_temps(code) + + def generate_subexpr_disposal_code(self, code): + self.subexpression.generate_disposal_code(code) + def generate_evaluation_code(self, code): self.setup_temp_expr(code) self.subexpression.generate_evaluation_code(code)