We had set the deafult optimization to 1 by the patch 04-default-is-optimized.patch, the assert doesn't work when optimization is 1, both native and target have this patch, but they are different, the target's optimization can be disabled by the "-N" option, the native python doesn't have the "-N" option. I think that we have two solutions: 1) Add the "-N" option for the native python or 2) We won't set the optimization by default just like other distributions do, the user can set it by the "-O" option, we have removed the "-O" and "-OO" option currently.
What issue are you trying to solve?
(In reply to comment #1) > What issue are you trying to solve? Hi Saul, the 'assert' statement doesn't work which would cause/hide unexpected errors, and it is a widely used statement, e.g., the 'assert False' should raise an exception, but it doesn't since we have hard coded the default optimizaton to 1 (the assert would work when optimization is 0), usually, the python would work like this: Set the default optimizaton to 0 (and use -O/-OO to optimize when the user needs), we have set the default optimizaton to 1 by default ( we have disabled to -O/-OO, there is a "-N" option for the target python, but no such an option for the native python), my suggestions are: 1) We would not set the default optimization to 1, and don't disable the -O/-OO Or 2) If we want to set it, we should not change the source code to hard code it, we can "export PYTHONOPTIMIZE=1 or 2" in the env by default. Or 3) I think that we should do no optimization for the native python by default.
Merged into master: http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=2f7c588c5a8148eec37405186c34bdd1425ea30b
Verified with poky(master:176a46b088135f2891983bb8540bc45389341d90) Native test log: wrsadmin@pek-nzhang0-d3:/home/yocto/20130527/tmp/sysroots/x86_64-linux/usr/bin/python-native$ python -N Unknown option: -N Unknown option: -N usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information. wrsadmin@pek-nzhang0-d3:/home/yocto/20130527/tmp/sysroots/x86_64-linux/usr/bin/python-native$ python -O Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> assert False >>> wrsadmin@pek-nzhang0-d3:/home/yocto/20130527/tmp/sysroots/x86_64-linux/usr/bin/python-native$ python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> assert False Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError Target python test result is same.