Fix SF buf #480096: Assign to __debug__ still allowed
Easy enough to catch assignment in the compiler. The perverse user
can still change the value of __debug__, but that may be the least he
can do.
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 9f20ba1..e976a30 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1,6 +1,17 @@
from test_support import verbose, TestFailed
if verbose:
+ print "Testing whether compiler catches assignment to __debug__"
+
+try:
+ compile('__debug__ = 1', '?', 'single')
+except SyntaxError:
+ pass
+
+import __builtin__
+setattr(__builtin__, '__debug__', 'sure')
+
+if verbose:
print 'Running tests on argument handling'
try:
@@ -21,7 +32,8 @@
except SyntaxError:
pass
-print "testing complex args"
+if verbose:
+ print "testing complex args"
def comp_args((a, b)):
print a,b