Commit 8a141881 authored by Robert Bradshaw's avatar Robert Bradshaw

Move assert exception object creation inside assert if block

parent 483a99c3
...@@ -2174,15 +2174,15 @@ class AssertStatNode(StatNode): ...@@ -2174,15 +2174,15 @@ class AssertStatNode(StatNode):
def generate_execution_code(self, code): def generate_execution_code(self, code):
code.putln("#ifndef PYREX_WITHOUT_ASSERTIONS") code.putln("#ifndef PYREX_WITHOUT_ASSERTIONS")
self.cond.generate_evaluation_code(code) self.cond.generate_evaluation_code(code)
if self.value:
self.value.generate_evaluation_code(code)
code.putln( code.putln(
"if (unlikely(!%s)) {" % "if (unlikely(!%s)) {" %
self.cond.result_code) self.cond.result_code)
if self.value: if self.value:
self.value.generate_evaluation_code(code)
code.putln( code.putln(
"PyErr_SetObject(PyExc_AssertionError, %s);" % "PyErr_SetObject(PyExc_AssertionError, %s);" %
self.value.py_result()) self.value.py_result())
self.value.generate_disposal_code(code)
else: else:
code.putln( code.putln(
"PyErr_SetNone(PyExc_AssertionError);") "PyErr_SetNone(PyExc_AssertionError);")
...@@ -2191,8 +2191,6 @@ class AssertStatNode(StatNode): ...@@ -2191,8 +2191,6 @@ class AssertStatNode(StatNode):
code.putln( code.putln(
"}") "}")
self.cond.generate_disposal_code(code) self.cond.generate_disposal_code(code)
if self.value:
self.value.generate_disposal_code(code)
code.putln("#endif") code.putln("#endif")
class IfStatNode(StatNode): class IfStatNode(StatNode):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment