如何禁用pypy assert语句?

时间:2012-12-27 07:57:39

标签: python pypy

$ ./pypy -O
Python 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26)
[PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: `` amd64 and ppc are only
available in enterprise version''
>>>> assert 1==2
Traceback (most recent call last):
  File "", line 1, in 
AssertionError
>>>> 

但是当我执行

$ 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 1==2
>>>

1 个答案:

答案 0 :(得分:5)

PyPy默默地忽略-O。其背后的原因是我们相信-O更改语义会严重破坏,但我认为这是非法的。随意发布一个错误(这也是这些报告所属的地方,在bugs.pypy.org上)