[3.9] bpo-25130: Make unit-test about restricting the maximum number … · python/cpython@1046cd0 (original) (raw)
`@@ -531,38 +531,6 @@
`
531
531
` ...
`
532
532
` SyntaxError: 'break' outside loop
`
533
533
``
534
``
`-
This raises a SyntaxError, it used to raise a SystemError.
`
535
``
`-
Context for this change can be found on issue #27514
`
536
``
-
537
``
`-
In 2.5 there was a missing exception and an assert was triggered in a debug
`
538
``
`-
build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
`
539
``
-
540
``
`-
while 1:
`
541
``
`-
... while 2:
`
542
``
`-
... while 3:
`
543
``
`-
... while 4:
`
544
``
`-
... while 5:
`
545
``
`-
... while 6:
`
546
``
`-
... while 8:
`
547
``
`-
... while 9:
`
548
``
`-
... while 10:
`
549
``
`-
... while 11:
`
550
``
`-
... while 12:
`
551
``
`-
... while 13:
`
552
``
`-
... while 14:
`
553
``
`-
... while 15:
`
554
``
`-
... while 16:
`
555
``
`-
... while 17:
`
556
``
`-
... while 18:
`
557
``
`-
... while 19:
`
558
``
`-
... while 20:
`
559
``
`-
... while 21:
`
560
``
`-
... while 22:
`
561
``
`-
... break
`
562
``
`-
Traceback (most recent call last):
`
563
``
`-
...
`
564
``
`-
SyntaxError: too many statically nested blocks
`
565
``
-
566
534
`Misuse of the nonlocal and global statement can lead to a few unique syntax errors.
`
567
535
``
568
536
` >>> def f():
`
`@@ -995,6 +963,42 @@ def test_invalid_line_continuation_left_recursive(self):
`
995
963
`self._check_error("A.\u03bc\\n",
`
996
964
`"unexpected EOF while parsing")
`
997
965
``
``
966
`+
@support.cpython_only
`
``
967
`+
def test_syntax_error_on_deeply_nested_blocks(self):
`
``
968
`+
This raises a SyntaxError, it used to raise a SystemError. Context
`
``
969
`+
for this change can be found on issue #27514
`
``
970
+
``
971
`+
In 2.5 there was a missing exception and an assert was triggered in a
`
``
972
`+
debug build. The number of blocks must be greater than CO_MAXBLOCKS.
`
``
973
`+
SF #1565514
`
``
974
+
``
975
`+
source = """
`
``
976
`+
while 1:
`
``
977
`+
while 2:
`
``
978
`+
while 3:
`
``
979
`+
while 4:
`
``
980
`+
while 5:
`
``
981
`+
while 6:
`
``
982
`+
while 8:
`
``
983
`+
while 9:
`
``
984
`+
while 10:
`
``
985
`+
while 11:
`
``
986
`+
while 12:
`
``
987
`+
while 13:
`
``
988
`+
while 14:
`
``
989
`+
while 15:
`
``
990
`+
while 16:
`
``
991
`+
while 17:
`
``
992
`+
while 18:
`
``
993
`+
while 19:
`
``
994
`+
while 20:
`
``
995
`+
while 21:
`
``
996
`+
while 22:
`
``
997
`+
break
`
``
998
`+
"""
`
``
999
`+
self._check_error(source, "too many statically nested blocks")
`
``
1000
+
``
1001
+
998
1002
`def test_main():
`
999
1003
`support.run_unittest(SyntaxTestCase)
`
1000
1004
`from test import test_syntax
`