Asserts are not removed with PYTHONOPTIMIZE
Created originally on Bitbucket by paiv (Pavel Ivashkov)
When optimization flag set, assert
should be removed:
-O : skip assert statements; also PYTHONOPTIMIZE=x
-OO : remove docstrings when importing modules in addition to -O
PYTHONOPTIMIZE
If this is set to a non-empty string it is equivalent to specifying
the -O option. If set to an integer, it is equivalent to specifying
-O multiple times.
Actual result:
$ pypy3 -O
Python 3.5.3 (fdd60ed87e941677e8ea11acf9f1819466521bf2, Jul 30 2018, 08:59:51)
[PyPy 6.0.0 with GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> __debug__
False
>>>> assert False
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
What was expected:
$ python3 -O
Python 3.7.0 (default, Jun 28 2018, 05:55:06)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> __debug__
False
>>> assert False
>>>