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: Assignment to __builtins__.__debug__ doesn't do anything.
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: jemfinch, rhettinger, tim.peters
Priority: normal Keywords:

Created on 2003-12-18 23:55 by jemfinch, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg19440 - (view) Author: Jeremy Fincher (jemfinch) Date: 2003-12-18 23:55
In 2.2, it would dynamically turn off asserts: 
 
Python 2.2.3+ (#1, Sep 30 2003, 01:19:08) 
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2 
Type "help", "copyright", "credits" or "license" for more 
information. 
>>> __debug__ 
1 
>>> __builtins__.__debug__ = 0 
>>> assert 0, "There should be nothing raised." 
>>> 
 
But in 2.3, this changed: 
 
Python 2.3.2 (#2, Nov 11 2003, 00:22:57) 
[GCC 3.3.2 (Debian)] on linux2 
Type "help", "copyright", "credits" or "license" for more 
information. 
>>> __debug__ 
True 
>>> __builtins__debug__ = False 
>>> assert 0, "There should be nothing raised." 
Traceback (most recent call last): 
  File "<stdin>", line 1, in ? 
AssertionError: There should be nothing raised. 
>>> 
 
If this is in fact the intended behavior (I hope it's not) then 
what's an application author to do when he wants to offer 
users a -O option *to his application* that turns off asserts? 
msg19441 - (view) Author: Jeremy Fincher (jemfinch) Date: 2004-01-16 03:38
Logged In: YES 
user_id=99508

Is this something that's likely to get fixed, or is it
something that I should start developing a workaround for?
msg19442 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-01-16 04:08
Logged In: YES 
user_id=31435

The NEWS file in your Python distribution, under the notes for 
2.3 alpha 1, says:

"""
- The assert statement no longer tests __debug__ at 
runtime.  This means that assert statements cannot be 
disabled by assigning a false value to __debug__.
"""

Do a Google search on

site:mail.python.org python-dev assert __debug__

if you want to read a lot more about it.  The decision on 
Guido's part was certainly intentional.  If people had griped 
during the extremely long alpha/beta/release_candidate 2.3 
cycle, he might have backed off -- but nobody did, so you're 
best off to consider this one a dead issue.
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39717
2003-12-18 23:55:52jemfinchcreate