[Python-checkins] CVS: python/dist/src/Python compile.c,2.140,2.141
Fred L. Drake
python-dev@python.org
Fri, 8 Sep 2000 09:31:27 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17274/Python
Modified Files:
compile.c
Log Message:
com_continue_stmt(): Improve error message when continue is found
in a try statement in a loop.
This is related to SourceForge bug #110830.
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.140
retrieving revision 2.141
diff -C2 -r2.140 -r2.141
*** compile.c 2000/09/02 20:11:27 2.140
--- compile.c 2000/09/08 16:31:24 2.141
***************
*** 259,263 ****
struct compiling {
! PyObject *c_code; /* string */
PyObject *c_consts; /* list of objects */
PyObject *c_const_dict; /* inverse of c_consts */
--- 259,263 ----
struct compiling {
! PyObject *c_code; /* string */
PyObject *c_consts; /* list of objects */
PyObject *c_const_dict; /* inverse of c_consts */
***************
*** 2934,2938 ****
--- 2934,2959 ----
com_addoparg(c, JUMP_ABSOLUTE, c->c_begin);
}
+ else if (i <= 0) {
+ /* at the outer level */
+ com_error(c, PyExc_SyntaxError,
+ "'continue' not properly in loop");
+ }
else {
+ int j;
+ for (j = 0; j <= i; ++j) {
+ if (c->c_block[j] == SETUP_LOOP)
+ break;
+ }
+ if (j < i+1) {
+ /* there is a loop, but something interferes */
+ for (++j; j <= i; ++j) {
+ if (c->c_block[i] == SETUP_EXCEPT
+ || c->c_block[i] == SETUP_FINALLY) {
+ com_error(c, PyExc_SyntaxError,
+ "'continue' not supported inside 'try' clause");
+ return;
+ }
+ }
+ }
com_error(c, PyExc_SyntaxError,
"'continue' not properly in loop");