]> granicus.if.org Git - python/commitdiff
make too many nested blocks be a SyntaxError instead of a SystemError (closes #27514)
authorBenjamin Peterson <benjamin@python.org>
Fri, 15 Jul 2016 05:00:03 +0000 (22:00 -0700)
committerBenjamin Peterson <benjamin@python.org>
Fri, 15 Jul 2016 05:00:03 +0000 (22:00 -0700)
Patch by Ammar Askar.

Lib/test/test_syntax.py
Misc/NEWS
Python/compile.c

index 057441c83c0f7109a3d7565efb4359836533dbd5..83f49f65802727756c63747fb8e5f48310c01251 100644 (file)
@@ -342,7 +342,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
 
@@ -370,7 +372,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.
 
index 835304b5f986034f8ed2d0c4047f5c2cdab119ce..f10544c381cce4c4e459c7797f3098c7d0fff86c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Release date: TBA
 Core and Builtins
 -----------------
 
+- Issue #27514: Make having too many statically nested blocks a SyntaxError
+  instead of SystemError.
+
 - Issue #27473: Fixed possible integer overflow in bytes and bytearray
   concatenations.  Patch by Xiang Zhang.
 
index ce510aa731223058e6b4b3f498ffcd8e6c46ef2b..93f47e0220f6e8a791561d394f50a18929b4f8fe 100644 (file)
@@ -3980,7 +3980,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;
     }