mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-27169: The __debug__ constant is now optimized out at compile time. (#4880)
This fixes also bpo-22091.
This commit is contained in:
parent
297fd876aa
commit
3325a6780c
4 changed files with 26 additions and 38 deletions
|
@ -337,16 +337,16 @@ class BuiltinTest(unittest.TestCase):
|
|||
try:
|
||||
assert False
|
||||
except AssertionError:
|
||||
return (True, f.__doc__, debug_enabled)
|
||||
return (True, f.__doc__, debug_enabled, __debug__)
|
||||
else:
|
||||
return (False, f.__doc__, debug_enabled)
|
||||
return (False, f.__doc__, debug_enabled, __debug__)
|
||||
'''
|
||||
def f(): """doc"""
|
||||
values = [(-1, __debug__, f.__doc__, __debug__),
|
||||
(0, True, 'doc', True),
|
||||
(1, False, 'doc', False),
|
||||
(2, False, None, False)]
|
||||
for optval, assertval, docstring, debugval in values:
|
||||
values = [(-1, __debug__, f.__doc__, __debug__, __debug__),
|
||||
(0, True, 'doc', True, True),
|
||||
(1, False, 'doc', False, False),
|
||||
(2, False, None, False, False)]
|
||||
for optval, *expected in values:
|
||||
# test both direct compilation and compilation via AST
|
||||
codeobjs = []
|
||||
codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
|
||||
|
@ -356,7 +356,7 @@ class BuiltinTest(unittest.TestCase):
|
|||
ns = {}
|
||||
exec(code, ns)
|
||||
rv = ns['f']()
|
||||
self.assertEqual(rv, (assertval, docstring, debugval))
|
||||
self.assertEqual(rv, tuple(expected))
|
||||
|
||||
def test_delattr(self):
|
||||
sys.spam = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue