From 8a141881b04a5b561b9e2f4f0b28a3a6cab11f63 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 1 Nov 2007 15:46:52 -0700 Subject: [PATCH] Move assert exception object creation inside assert if block --- Cython/Compiler/Nodes.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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): -- 2.26.2