Skip to content

Commit e86a7be

Browse files
committed
Use a "yield" parameter instead of a "discard" parameter.
1 parent 9fe6718 commit e86a7be

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Python/codegen.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,20 +4561,18 @@ codegen_comprehension_generator(compiler *c, location loc,
45614561
}
45624562

45634563
static int
4564-
codegen_unpack_starred(compiler *c, location loc, expr_ty value, bool discard)
4564+
codegen_unpack_starred(compiler *c, location loc, expr_ty value, bool yield)
45654565
{
45664566
NEW_JUMP_TARGET_LABEL(c, unpack_start);
45674567
NEW_JUMP_TARGET_LABEL(c, unpack_end);
45684568
VISIT(c, expr, value);
45694569
ADDOP_I(c, loc, GET_ITER, 0);
45704570
USE_LABEL(c, unpack_start);
45714571
ADDOP_JUMP(c, loc, FOR_ITER, unpack_end);
4572-
if (discard) {
4573-
ADDOP(c, loc, POP_TOP);
4574-
} else {
4572+
if (yield) {
45754573
ADDOP_YIELD(c, loc);
4576-
ADDOP(c, loc, POP_TOP);
45774574
}
4575+
ADDOP(c, loc, POP_TOP);
45784576
ADDOP_JUMP(c, NO_LOCATION, JUMP, unpack_start);
45794577
USE_LABEL(c, unpack_end);
45804578
ADDOP(c, NO_LOCATION, END_FOR);
@@ -4667,7 +4665,7 @@ codegen_sync_comprehension_generator(compiler *c, location loc,
46674665
case COMP_GENEXP:
46684666
assert(!avoid_creation);
46694667
if (elt->kind == Starred_kind) {
4670-
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*discard=*/false));
4668+
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/true));
46714669
}
46724670
else {
46734671
VISIT(c, expr, elt);
@@ -4678,7 +4676,7 @@ codegen_sync_comprehension_generator(compiler *c, location loc,
46784676
case COMP_LISTCOMP:
46794677
if (avoid_creation) {
46804678
if (elt->kind == Starred_kind) {
4681-
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*discard=*/true));
4679+
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/false));
46824680
} else {
46834681
VISIT(c, expr, elt);
46844682
ADDOP(c, elt_loc, POP_TOP);
@@ -4831,7 +4829,7 @@ codegen_async_comprehension_generator(compiler *c, location loc,
48314829
case COMP_LISTCOMP:
48324830
if (avoid_creation) {
48334831
if (elt->kind == Starred_kind) {
4834-
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*discard=*/false));
4832+
RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/false));
48354833
} else {
48364834
VISIT(c, expr, elt);
48374835
ADDOP(c, elt_loc, POP_TOP);

0 commit comments

Comments
 (0)