changeset: 102351:345ec7455b75 branch: 2.7 parent: 102342:2d6e6600c210 user: Benjamin Peterson date: Thu Jul 14 22:00:03 2016 -0700 files: Lib/test/test_syntax.py Misc/NEWS Python/compile.c description: make too many nested blocks be a SyntaxError instead of a SystemError (closes #27514) Patch by Ammar Askar. diff -r 2d6e6600c210 -r 345ec7455b75 Lib/test/test_syntax.py --- a/Lib/test/test_syntax.py Thu Jul 14 01:31:46 2016 +0000 +++ b/Lib/test/test_syntax.py Thu Jul 14 22:00:03 2016 -0700 @@ -371,7 +371,9 @@ File "", line 3 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 @@ -399,7 +401,7 @@ ... break Traceback (most recent call last): ... - SystemError: too many statically nested blocks + SyntaxError: too many statically nested blocks This tests assignment-context; there was a bug in Python 2.5 where compiling a complex 'if' (one with 'elif') would fail to notice an invalid suite, diff -r 2d6e6600c210 -r 345ec7455b75 Misc/NEWS --- a/Misc/NEWS Thu Jul 14 01:31:46 2016 +0000 +++ b/Misc/NEWS Thu Jul 14 22:00:03 2016 -0700 @@ -17,6 +17,9 @@ unicode paths with embedded null character on Windows instead of silently truncating them. +- Issue #27514: Make having too many statically nested blocks a SyntaxError + instead of SystemError. + Library ------- diff -r 2d6e6600c210 -r 345ec7455b75 Python/compile.c --- a/Python/compile.c Thu Jul 14 01:31:46 2016 +0000 +++ b/Python/compile.c Thu Jul 14 22:00:03 2016 -0700 @@ -3147,7 +3147,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; }