[Python-Dev] Assigning to __debug__

M.-A. Lemburg mal@lemburg.com
Fri, 30 Mar 2001 10:06:42 +0200


"Martin v. Loewis" wrote:
> 
> After the recent change that assignments to __debug__ are disallowed,
> I noticed that IDLE stops working (see SF bug report), since it was
> assigning to __debug__.
> 
> Simply commenting-out the assignment (to zero) did no good: Inside the
> __debug__ blocks, IDLE would try to perform print statements, which
> would write to the re-assigned sys.stdout, which would invoke the code
> that had the __debug__, which would give up thanks to infinite
> recursion. So essentially, you either have to remove the __debug__
> blocks, or rewrite them to writing to save_stdout - in which case all
> the ColorDelegator debug message appear in the terminal window.
> 
> So anybody porting to Python 2.1 will essentially have to remove all
> __debug__ blocks that were previously disabled by assigning 0 to
> __debug__. I think this is undesirable.
> 
> As I recall, in the original description of __debug__, being able to
> assign to it was reported as one of its main features, so that you
> still had a run-time option (unless the interpreter was running with
> -O, which eliminates the __debug__ blocks).
> 
> So in short, I think this change should be reverted.

+1 from here... 

I use the same concept for debugging: during development I set 
__debug__ to 1, in production I change it to 0 (python -O does this
for me as well).

> Regards,
> Martin
> 
> P.S. What was the motivation for that change, anyway?
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Pages:                           http://www.lemburg.com/python/