"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).
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