From: Robert Bradshaw Date: Thu, 1 Nov 2007 22:46:52 +0000 (-0700) Subject: Move assert exception object creation inside assert if block X-Git-Tag: 0.9.6.14~29^2~99 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a141881b04a5b561b9e2f4f0b28a3a6cab11f63;p=cython.git Move assert exception object creation inside assert if block --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 83ef12b4..d5a8887d 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2174,15 +2174,15 @@ class AssertStatNode(StatNode): def generate_execution_code(self, code): code.putln("#ifndef PYREX_WITHOUT_ASSERTIONS") self.cond.generate_evaluation_code(code) - if self.value: - self.value.generate_evaluation_code(code) code.putln( "if (unlikely(!%s)) {" % self.cond.result_code) if self.value: + self.value.generate_evaluation_code(code) code.putln( "PyErr_SetObject(PyExc_AssertionError, %s);" % self.value.py_result()) + self.value.generate_disposal_code(code) else: code.putln( "PyErr_SetNone(PyExc_AssertionError);") @@ -2191,8 +2191,6 @@ class AssertStatNode(StatNode): code.putln( "}") self.cond.generate_disposal_code(code) - if self.value: - self.value.generate_disposal_code(code) code.putln("#endif") class IfStatNode(StatNode):