Skip to content

Commit

Permalink
make too many nested blocks be a SyntaxError instead of a SystemError (
Browse files Browse the repository at this point in the history
…closes python#27514)

Patch by Ammar Askar.
  • Loading branch information
benjaminp committed Jul 15, 2016
1 parent 65e0d8c commit 6c4fa70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@
File "<doctest test.test_syntax[42]>", 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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Core and Builtins
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
-------

Expand Down
2 changes: 1 addition & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3147,7 +3147,7 @@ compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
{
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;
}
Expand Down

0 comments on commit 6c4fa70

Please sign in to comment.