Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
calculate once
  • Loading branch information
iritkatriel committed Apr 29, 2024
commit 39d64f2e8fe1e46a18eaf2d225c7bb0bcee4175e
5 changes: 3 additions & 2 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,8 @@ compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t f

NEW_JUMP_TARGET_LABEL(c, start);
USE_LABEL(c, start);
if (c->u->u_ste->ste_coroutine || c->u->u_ste->ste_generator) {
bool add_stopiteration_handler = c->u->u_ste->ste_coroutine || c->u->u_ste->ste_generator;
if (add_stopiteration_handler) {
/* wrap_in_stopiteration_handler will push a block, so we need to account for that */
RETURN_IF_ERROR(
compiler_push_fblock(c, NO_LOCATION, STOP_ITERATION,
Expand All @@ -2247,7 +2248,7 @@ compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t f
for (Py_ssize_t i = first_instr; i < asdl_seq_LEN(body); i++) {
VISIT_IN_SCOPE(c, stmt, (stmt_ty)asdl_seq_GET(body, i));
}
if (c->u->u_ste->ste_coroutine || c->u->u_ste->ste_generator) {
if (add_stopiteration_handler) {
if (wrap_in_stopiteration_handler(c) < 0) {
compiler_exit_scope(c);
return ERROR;
Expand Down