bpo-25130: Make unit-test about restricting the maximum number of nes… · python/cpython@779b9ae (original) (raw)
`@@ -629,38 +629,6 @@
`
629
629
` ...
`
630
630
` SyntaxError: 'break' outside loop
`
631
631
``
632
``
`-
This raises a SyntaxError, it used to raise a SystemError.
`
633
``
`-
Context for this change can be found on issue #27514
`
634
``
-
635
``
`-
In 2.5 there was a missing exception and an assert was triggered in a debug
`
636
``
`-
build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
`
637
``
-
638
``
`-
while 1:
`
639
``
`-
... while 2:
`
640
``
`-
... while 3:
`
641
``
`-
... while 4:
`
642
``
`-
... while 5:
`
643
``
`-
... while 6:
`
644
``
`-
... while 8:
`
645
``
`-
... while 9:
`
646
``
`-
... while 10:
`
647
``
`-
... while 11:
`
648
``
`-
... while 12:
`
649
``
`-
... while 13:
`
650
``
`-
... while 14:
`
651
``
`-
... while 15:
`
652
``
`-
... while 16:
`
653
``
`-
... while 17:
`
654
``
`-
... while 18:
`
655
``
`-
... while 19:
`
656
``
`-
... while 20:
`
657
``
`-
... while 21:
`
658
``
`-
... while 22:
`
659
``
`-
... break
`
660
``
`-
Traceback (most recent call last):
`
661
``
`-
...
`
662
``
`-
SyntaxError: too many statically nested blocks
`
663
``
-
664
632
`Misuse of the nonlocal and global statement can lead to a few unique syntax errors.
`
665
633
``
666
634
` >>> def f():
`
`@@ -1550,6 +1518,41 @@ def test_multiline_compiler_error_points_to_the_end(self):
`
1550
1518
`lineno=3
`
1551
1519
` )
`
1552
1520
``
``
1521
`+
@support.cpython_only
`
``
1522
`+
def test_syntax_error_on_deeply_nested_blocks(self):
`
``
1523
`+
This raises a SyntaxError, it used to raise a SystemError. Context
`
``
1524
`+
for this change can be found on issue #27514
`
``
1525
+
``
1526
`+
In 2.5 there was a missing exception and an assert was triggered in a
`
``
1527
`+
debug build. The number of blocks must be greater than CO_MAXBLOCKS.
`
``
1528
`+
SF #1565514
`
``
1529
+
``
1530
`+
source = """
`
``
1531
`+
while 1:
`
``
1532
`+
while 2:
`
``
1533
`+
while 3:
`
``
1534
`+
while 4:
`
``
1535
`+
while 5:
`
``
1536
`+
while 6:
`
``
1537
`+
while 8:
`
``
1538
`+
while 9:
`
``
1539
`+
while 10:
`
``
1540
`+
while 11:
`
``
1541
`+
while 12:
`
``
1542
`+
while 13:
`
``
1543
`+
while 14:
`
``
1544
`+
while 15:
`
``
1545
`+
while 16:
`
``
1546
`+
while 17:
`
``
1547
`+
while 18:
`
``
1548
`+
while 19:
`
``
1549
`+
while 20:
`
``
1550
`+
while 21:
`
``
1551
`+
while 22:
`
``
1552
`+
break
`
``
1553
`+
"""
`
``
1554
`+
self._check_error(source, "too many statically nested blocks")
`
``
1555
+
1553
1556
``
1554
1557
`def test_main():
`
1555
1558
`support.run_unittest(SyntaxTestCase)
`