Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,24 @@ def test_compile_warnings(self):

self.assertEqual(len(caught), 2)

def test_compile_warning_in_finally(self):
# Ensure that warnings inside finally blocks are
# only emitted once despite the block being
# compiled twice (for normal execution and for
# exception handling).
source = textwrap.dedent("""
try:
pass
finally:
1 is 1
""")

with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("default")
compile(source, '<stdin>', 'exec')

self.assertEqual(len(caught), 1)

class TestBooleanExpression(unittest.TestCase):
class Value:
def __init__(self):
Expand Down
Loading