[Python-checkins] r52504 - in python/trunk: Lib/test/test_syntax.py Misc/NEWS Python/compile.c

neal.norwitz python-checkins at python.org
Sat Oct 28 23:19:08 CEST 2006


Author: neal.norwitz
Date: Sat Oct 28 23:19:07 2006
New Revision: 52504
Modified:
 python/trunk/Lib/test/test_syntax.py
 python/trunk/Misc/NEWS
 python/trunk/Python/compile.c
Log:
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.
Will backport.
Modified: python/trunk/Lib/test/test_syntax.py
==============================================================================
--- python/trunk/Lib/test/test_syntax.py	(original)
+++ python/trunk/Lib/test/test_syntax.py	Sat Oct 28 23:19:07 2006
@@ -336,6 +336,37 @@
 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
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Oct 28 23:19:07 2006
@@ -12,6 +12,8 @@
 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.
 
Modified: python/trunk/Python/compile.c
==============================================================================
--- python/trunk/Python/compile.c	(original)
+++ python/trunk/Python/compile.c	Sat Oct 28 23:19:07 2006
@@ -3131,8 +3131,11 @@
 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;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /