[Pyrex] Compiling without assertions

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Tue Jun 6 07:36:13 UTC 2006


Hi,

this trivial patch allows compiling out all "assert" statements by defining
PYREX_WITHOUT_ASSERTIONS in the C compiler (through distutils, a header file,
compiler option or whatever).

Stefan


Index: Pyrex/Compiler/Nodes.py
===================================================================
--- Pyrex/Compiler/Nodes.py     (Revision 136)
+++ Pyrex/Compiler/Nodes.py     (Arbeitskopie)
@@ -2896,6 +2896,7 @@
         #env.recycle_pending_temps() # TEMPORARY

     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)
@@ -2916,6 +2917,7 @@
         self.cond.generate_disposal_code(code)
         if self.value:
             self.value.generate_disposal_code(code)
+        code.putln("#endif")


 class IfStatNode(StatNode):



More information about the Pyrex mailing list