This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: assert fail to threw exception when run python with '-O'
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: tim.peters, tj128
Priority: normal Keywords:

Created on 2004-12-02 20:02 by tj128, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg23532 - (view) Author: tj128 (tj128) Date: 2004-12-02 20:02
in both 2.3 and 2.4 version, if you run 'python -O', 
assert fail to threw excetption when it should.

example

>python -O
Python 2.3.3 (#4, Apr 11 2004, 12:01:37) 
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-20)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
>>> try:
...  assert(1==2)
...  print 'yyy'
... except:
...  print 'zzz'
... 
yyy
>>> 
msg23533 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-12-02 20:07
Logged In: YES 
user_id=31435

That's correct, but it's a deliberate and documented feature.  
Please read the docs for the assert statement:

http://docs.python.org/ref/assert.html
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41276
2004-12-02 20:02:53tj128create