Move assert exception object creation inside assert if block
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 22:46:52 +0000 (15:46 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 22:46:52 +0000 (15:46 -0700)
Cython/Compiler/Nodes.py

index 83ef12b4a34bf07065a4f3f3074d2acf7a4e1b1a..d5a8887d29f5e3f9bb5ea4f8cbc71836c054ab01 100644 (file)
@@ -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):