bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)

* Account for control blocks in 'except' in compiler. Fixes #39934.
This commit is contained in:
Mark Shannon 2020-09-25 14:04:19 +01:00 committed by GitHub
parent 05cc881cbc
commit 02d126aa09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View file

@ -950,6 +950,15 @@ pass
except SyntaxError:
self.fail("Empty line after a line continuation character is valid.")
@support.cpython_only
def test_nested_named_except_blocks(self):
code = ""
for i in range(12):
code += f"{' '*i}try:\n"
code += f"{' '*(i+1)}raise Exception\n"
code += f"{' '*i}except Exception as e:\n"
code += f"{' '*4*12}pass"
self._check_error(code, "too many statically nested blocks")
def test_main():
support.run_unittest(SyntaxTestCase)