[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.107, 1.1.2.108

nascheme@users.sourceforge.net nascheme at users.sourceforge.net
Thu Jun 2 07:14:37 CEST 2005


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

Modified Files:
      Tag: ast-branch
	newcompile.c 
Log Message:
Use block type attribute from symbol table to catch 'return' and 'yield'
syntax errors.


Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.107
retrieving revision 1.1.2.108
diff -u -d -r1.1.2.107 -r1.1.2.108
--- newcompile.c	15 Apr 2005 01:49:23 -0000	1.1.2.107
+++ newcompile.c	2 Jun 2005 05:14:34 -0000	1.1.2.108
@@ -1992,8 +1992,8 @@
         case ClassDef_kind:
 		return compiler_class(c, s);
         case Return_kind:
-                if (c->c_nestlevel <= 1)
-                        return compiler_error(c, "'return' outside function");
+		if (c->u->u_ste->ste_type != FunctionBlock)
+			return compiler_error(c, "'return' outside function");
 		if (s->v.Return.value) {
 			if (c->u->u_ste->ste_generator) {
 				return compiler_error(c,
@@ -2006,7 +2006,7 @@
 		ADDOP(c, RETURN_VALUE);
 		break;
         case Yield_kind:
-                if (c->c_nestlevel <= 1)
+		if (c->u->u_ste->ste_type != FunctionBlock)
                         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)



More information about the Python-checkins mailing list