8000 Cleanup · python/cpython@a0953b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a0953b1

Browse files
committed
Cleanup
1 parent 4b0e60f commit a0953b1

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Python/compile.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,35 +1946,36 @@ compiler_call_exit_with_nones(struct compiler *c) {
19461946
static int
19471947
compiler_add_yield_from(struct compiler *c, int await)
19481948
{
1949-
NEW_JUMP_TARGET_LABEL(c, start);
1950-
NEW_JUMP_TARGET_LABEL(c, resume);
1951-
NEW_JUMP_TARGET_LABEL(c, error);
1952-
NEW_JUMP_TARGET_LABEL(c, stopiter);
1949+
NEW_JUMP_TARGET_LABEL(c, send);
1950+
NEW_JUMP_TARGET_LABEL(c, fail);
1951+
NEW_JUMP_TARGET_LABEL(c, stop);
19531952
NEW_JUMP_TARGET_LABEL(c, exit);
1954-
USE_LABEL(c, start);
1953+
1954+
USE_LABEL(c, send);
19551955
ADDOP_JUMP(c, SEND, exit);
1956-
USE_LABEL(c, resume);
1957-
// Set up a virtual try/except to handle StopIteration raised during a
1958-
// close() or throw():
1959-
ADDOP_JUMP(c, SETUP_FINALLY, error);
1960-
RETURN_IF_FALSE(compiler_push_fblock(c, TRY_EXCEPT, resume, NO_LABEL, NULL));
1961-
// The only way YIELD_VALUE can raise is if close() or throw() raises:
1956+
// Set up a virtual try/except to handle when StopIteration is raised during
1957+
// a close or throw call. The only way YIELD_VALUE raises if they do!
1958+
ADDOP_JUMP(c, SETUP_FINALLY, fail);
1959+
RETURN_IF_FALSE(compiler_push_fblock(c, TRY_EXCEPT, send, NO_LABEL, NULL));
19621960
ADDOP_I(c, YIELD_VALUE, 0);
1963-
compiler_pop_fblock(c, TRY_EXCEPT, resume);
1961+
compiler_pop_fblock(c, TRY_EXCEPT, send);
19641962
ADDOP_NOLINE(c, POP_BLOCK);
19651963
ADDOP_I(c, RESUME, await ? 3 : 2);
1966-
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start);
1967-
USE_LABEL(c, error);
1964+
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, send);
1965+
1966+
USE_LABEL(c, fail);
19681967
ADDOP_I(c, LOAD_EXCEPTION_TYPE, 1); // StopIteration
19691968
ADDOP(c, CHECK_EXC_MATCH);
1970-
ADDOP_JUMP(c, POP_JUMP_IF_TRUE, stopiter);
1969+
ADDOP_JUMP(c, POP_JUMP_IF_TRUE, stop);
19711970
ADDOP_I(c, RERAISE, 0);
1972-
USE_LABEL(c, stopiter);
1973-
// StopIteration was raised. Push the return value and continue execution:
1971+
1972+
USE_LABEL(c, stop);
1973+
// StopIteration was raised. Push the value and break out of the loop:
19741974
ADDOP_NAME(c, LOAD_ATTR, &_Py_ID(value), names);
19751975
ADDOP_I(c, SWAP, 3);
1976-
ADDOP(c, POP_TOP);
1977-
ADDOP(c, POP_TOP);
1976+
ADDOP(c, POP_TOP); // The thing we're yielding from.
1977+
ADDOP(c, POP_TOP); // The last sent value
1978+
19781979
USE_LABEL(c, exit);
19791980
return 1;
19801981
}

0 commit comments

Comments
 (0)
0