summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_syntax.py6
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/compile.c2
3 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 38fc417..f47bdf9 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -334,7 +334,9 @@ isn't, there should be a syntax error.
...
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 @@ build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
... 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 --git a/Misc/NEWS b/Misc/NEWS
index 02b0782..de7c09c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 alpha 4
Core and Builtins
-----------------
+- Issue #27514: Make having too many statically nested blocks a SyntaxError
+ instead of SystemError.
+
Library
-------
diff --git a/Python/compile.c b/Python/compile.c
index 687b750..e46676c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -4249,7 +4249,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;
}