]> 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 7994fe67e72b27d5bac3d68656d569306170d7ad..0a61462a608557df83556ae60c851d4ff406f597 100644 (file)
@@ -371,7 +371,9 @@ isn't, there should be a syntax error.
      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
 
@@ -399,7 +401,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
 
 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,
index 9ae2221c7db11a1d0540d62374ca22860c40ff07..7e762e8853909b89d2db770ffd18e08fec484649 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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
 -------
 
index ba93fb4bdc73e8e8f0e21022bb962b6692162248..9c9b23698520bb0fb4546d513f96d11b3076e010 100644 (file)
@@ -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;
     }