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
Prev Previous commit
Next Next commit
Merge branch 'main' into warn_explicit-no-module
  • Loading branch information
serhiy-storchaka committed Oct 30, 2025
commit b473aa953d52588d51e37a6a7fb41f357d5a9506
60 changes: 60 additions & 0 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,66 @@ def test_filter_syntax_warnings_by_module(self):
self.assertEqual(wm.filename, filename)
self.assertIs(wm.category, SyntaxWarning)

@support.subTests('src', [
textwrap.dedent("""
def f():
try:
pass
finally:
return 42
"""),
textwrap.dedent("""
for x in y:
try:
pass
finally:
break
"""),
textwrap.dedent("""
for x in y:
try:
pass
finally:
continue
"""),
])
def test_pep_765_warnings(self, src):
with self.assertWarnsRegex(SyntaxWarning, 'finally'):
compile(src, '<string>', 'exec')
with warnings.catch_warnings():
warnings.simplefilter("error")
tree = ast.parse(src)
with self.assertWarnsRegex(SyntaxWarning, 'finally'):
compile(tree, '<string>', 'exec')

@support.subTests('src', [
textwrap.dedent("""
try:
pass
finally:
def f():
return 42
"""),
textwrap.dedent("""
try:
pass
finally:
for x in y:
break
"""),
textwrap.dedent("""
try:
pass
finally:
for x in y:
continue
"""),
])
def test_pep_765_no_warnings(self, src):
with warnings.catch_warnings():
warnings.simplefilter("error")
compile(src, '<string>', 'exec')


class TestBooleanExpression(unittest.TestCase):
class Value:
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.