Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1bf198e commit 95c80f8Copy full SHA for 95c80f8
1 file changed
Python/compile.c
@@ -2659,10 +2659,20 @@ com_return_stmt(struct compiling *c, node *n)
2659
static void
2660
com_yield_stmt(struct compiling *c, node *n)
2661
{
2662
+ int i;
2663
REQ(n, yield_stmt); /* 'yield' testlist */
2664
if (!c->c_infunction) {
2665
com_error(c, PyExc_SyntaxError, "'yield' outside function");
2666
}
2667
+
2668
+ for (i = 0; i < c->c_nblocks; ++i) {
2669
+ if (c->c_block[i] == SETUP_FINALLY) {
2670
+ com_error(c, PyExc_SyntaxError,
2671
+ "'yield' not allowed in a 'try' block "
2672
+ "with a 'finally' clause");
2673
+ return;
2674
+ }
2675
2676
com_node(c, CHILD(n, 1));
2677
com_addbyte(c, YIELD_VALUE);
2678
com_pop(c, 1);
0 commit comments