Patchwork python's assert doesn't work

login
register
mail settings
Submitter Robert Yang
Date April 25, 2013, 1:09 p.m.
Message ID <51792B15.4010001@windriver.com>
Download mbox | patch
Permalink /patch/48891/
State New
Headers show

Comments

Robert Yang - April 25, 2013, 1:09 p.m.
Both native and target python's assert doesn't work, because python
has been optimized by default by us:


The optimization should be specified by the user, for example,  run by
"python -O/OO", or "export PYTHONOPTIMIZE" in the env, but we have hardcode
it, then we can't change it back to 0, and this causes the "assert" doesn't
work, e.g.: the "assert False" should raise error, but it doesn't, this may
hide or cause unexpected errors.

I'd like to send a patch to change it back if you are fine with it,
and we can set PYTHONOPTIMIZE in the env if we really need it, this
gives the user a way to disable the optimization.

Patch

--- Python-2.6.1.orig/Python/compile.c
+++ Python-2.6.1/Python/compile.c
@@ -32,7 +32,7 @@ 
  #include "symtable.h"
  #include "opcode.h"

-int Py_OptimizeFlag = 0;
+int Py_OptimizeFlag = 1;

  #define DEFAULT_BLOCK_SIZE 16
  #define DEFAULT_BLOCKS 8