We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 099b2a6 commit 81e5c50Copy full SHA for 81e5c50
Lib/test/test_compile.py
@@ -846,6 +846,19 @@ def continue_in_while():
846
self.assertEqual(None, opcodes[1].argval)
847
self.assertEqual('RETURN_VALUE', opcodes[2].opname)
848
849
+ def test_unloop_break_continue(self):
850
+ source_template = "with object() as obj:\n {}"
851
+ sources = []
852
+ for stmt in ('break', 'continue'):
853
+ sources.append((stmt, source_template.format(stmt)))
854
+
855
+ for stmt, source in sources:
856
+ with self.subTest(stmt=stmt):
857
+ with self.assertRaises(SyntaxError) as err_ctx:
858
+ compile(source, f"<unloop_{stmt}>", "exec")
859
+ exc = err_ctx.exception
860
+ self.assertEqual(exc.lineno, 2)
861
862
def test_consts_in_conditionals(self):
863
def and_true(x):
864
return True and x
0 commit comments