[Python-checkins] CVS: python/dist/src/Python compile.c,2.202,2.203
Tim Peters
tim_one@users.sourceforge.net
Fri, 22 Jun 2001 19:07:11 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv12658/python/dist/src/Python
Modified Files:
compile.c
Log Message:
Disallow 'yield' in a 'try' block when there's a 'finally' clause.
Derived from Thomas Wouters's patch on the Iterators list, but doesn't
try to read c->c_block[c->c_nblocks].
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.202
retrieving revision 2.203
diff -C2 -r2.202 -r2.203
*** compile.c 2001/06/18 22:08:13 2.202
--- compile.c 2001/06/23 02:07:08 2.203
***************
*** 2660,2666 ****
--- 2660,2676 ----
com_yield_stmt(struct compiling *c, node *n)
{
+ int i;
REQ(n, yield_stmt); /* 'yield' testlist */
if (!c->c_infunction) {
com_error(c, PyExc_SyntaxError, "'yield' outside function");
+ }
+
+ for (i = 0; i < c->c_nblocks; ++i) {
+ if (c->c_block[i] == SETUP_FINALLY) {
+ com_error(c, PyExc_SyntaxError,
+ "'yield' not allowed in a 'try' block "
+ "with a 'finally' clause");
+ return;
+ }
}
com_node(c, CHILD(n, 1));