[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.98, 1.1.2.99

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Fri Apr 23 23:01:56 EDT 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8572

Modified Files:
      Tag: ast-branch
	newcompile.c 
Log Message:
Report syntax errors tested by test_generators.


Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.98
retrieving revision 1.1.2.99
diff -C2 -d -r1.1.2.98 -r1.1.2.99
*** newcompile.c	23 Apr 2004 18:35:13 -0000	1.1.2.98
--- newcompile.c	24 Apr 2004 03:01:54 -0000	1.1.2.99
***************
*** 1833,1838 ****
                  if (c->c_nestlevel <= 1)
                          return compiler_error(c, "'return' outside function");
! 		if (s->v.Return.value)
! 			VISIT(c, expr, s->v.Return.value)
  		else
  			ADDOP_O(c, LOAD_CONST, Py_None, consts);
--- 1833,1843 ----
                  if (c->c_nestlevel <= 1)
                          return compiler_error(c, "'return' outside function");
! 		if (s->v.Return.value) {
! 			if (c->u->u_ste->ste_generator) {
! 				return compiler_error(c,
! 				    "'return' with argument inside generator");
! 			}
! 			VISIT(c, expr, s->v.Return.value);
! 		}
  		else
  			ADDOP_O(c, LOAD_CONST, Py_None, consts);
***************
*** 1842,1845 ****
--- 1847,1856 ----
                  if (c->c_nestlevel <= 1)
                          return compiler_error(c, "'yield' outside function");
+ 		for (i = 0; i < c->u->u_nfblocks; i++) {
+ 			if (c->u->u_fblock[i].fb_type == FINALLY_TRY)
+ 				return compiler_error(
+ 					c, "'yield' not allowed in a 'try' "
+ 					"block with a 'finally' clause");
+ 		}
  		VISIT(c, expr, s->v.Yield.value);
  		ADDOP(c, YIELD_VALUE);




More information about the Python-checkins mailing list