]> granicus.if.org Git - python/commitdiff
Backport 52504:
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 28 Oct 2006 21:38:43 +0000 (21:38 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 28 Oct 2006 21:38:43 +0000 (21:38 +0000)
Fix bug #1565514, SystemError not raised on too many nested blocks.
It seems like this should be a different error than SystemError, but
I don't have any great ideas and SystemError was raised in 2.4 and earlier.

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

index 521789f34641b045ad22f642f9d4152d5ac7b591..40991492a4391f6f3514a5793ae0aa6e380c4d5f 100644 (file)
@@ -333,6 +333,37 @@ isn't, there should be a syntax error.
    Traceback (most recent call last):
      ...
    SyntaxError: 'break' outside loop (<doctest test.test_syntax[42]>, line 3)
+
+This should probably raise a better error than a SystemError (or none at all).
+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
+
+   >>> while 1:
+   ...  while 2:
+   ...   while 3:
+   ...    while 4:
+   ...     while 5:
+   ...      while 6:
+   ...       while 8:
+   ...        while 9:
+   ...         while 10:
+   ...          while 11:
+   ...           while 12:
+   ...            while 13:
+   ...             while 14:
+   ...              while 15:
+   ...               while 16:
+   ...                while 17:
+   ...                 while 18:
+   ...                  while 19:
+   ...                   while 20:
+   ...                    while 21:
+   ...                     while 22:
+   ...                      break
+   Traceback (most recent call last):
+     ...
+   SystemError: too many statically nested blocks
+
 """
 
 import re
index 4150444c7ebbaa6f3d6d0cbc92920414137fa03a..f47c4e920ee87c8cc00a164b3fb1a8af9d41ba40 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.5.1c1?
 Core and builtins
 -----------------
 
+- Bug #1565514, SystemError not raised on too many nested blocks.
+
 - Bug #1576174: WindowsError now displays the windows error code
   again, no longer the posix error code.
 
index 038bc2f4fede9dc79c6c9395f77a42bc09ea2161..8be3d79be9f69e21a12e2267a3a3dcd8318b2b4c 100644 (file)
@@ -3738,8 +3738,11 @@ static int
 compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
 {
        struct fblockinfo *f;
-       if (c->u->u_nfblocks >= CO_MAXBLOCKS)
+       if (c->u->u_nfblocks >= CO_MAXBLOCKS) {
+               PyErr_SetString(PyExc_SystemError,
+                               "too many statically nested blocks");
                return 0;
+       }
        f = &c->u->u_fblock[c->u->u_nfblocks++];
        f->fb_type = t;
        f->fb_block = b;