diff -r 89821243621b Lib/test/test_syntax.py --- a/Lib/test/test_syntax.py Thu Jul 14 07:45:24 2016 +0300 +++ b/Lib/test/test_syntax.py Thu Jul 14 14:31:26 2016 -0700 @@ -334,7 +334,9 @@ ... SyntaxError: 'break' outside loop -This should probably raise a better error than a SystemError (or none at all). +This raises a SyntaxError, it used to raise a SystemError. +Context for this change can be found on issue #27514 + In 2.5 there was a missing exception and an assert was triggered in a debug build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514 @@ -362,7 +364,7 @@ ... break Traceback (most recent call last): ... - SystemError: too many statically nested blocks + SyntaxError: too many statically nested blocks Misuse of the nonlocal statement can lead to a few unique syntax errors. diff -r 89821243621b Python/compile.c --- a/Python/compile.c Thu Jul 14 07:45:24 2016 +0300 +++ b/Python/compile.c Thu Jul 14 14:31:26 2016 -0700 @@ -4249,7 +4249,7 @@ { struct fblockinfo *f; if (c->u->u_nfblocks >= CO_MAXBLOCKS) { - PyErr_SetString(PyExc_SystemError, + PyErr_SetString(PyExc_SyntaxError, "too many statically nested blocks"); return 0; }