mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression (#124394)
This commit is contained in:
parent
c58c572a65
commit
78aeb38f7d
14 changed files with 234 additions and 47 deletions
|
@ -3140,17 +3140,15 @@ codegen_boolop(compiler *c, expr_ty e)
|
|||
location loc = LOC(e);
|
||||
assert(e->kind == BoolOp_kind);
|
||||
if (e->v.BoolOp.op == And)
|
||||
jumpi = POP_JUMP_IF_FALSE;
|
||||
jumpi = JUMP_IF_FALSE;
|
||||
else
|
||||
jumpi = POP_JUMP_IF_TRUE;
|
||||
jumpi = JUMP_IF_TRUE;
|
||||
NEW_JUMP_TARGET_LABEL(c, end);
|
||||
s = e->v.BoolOp.values;
|
||||
n = asdl_seq_LEN(s) - 1;
|
||||
assert(n >= 0);
|
||||
for (i = 0; i < n; ++i) {
|
||||
VISIT(c, expr, (expr_ty)asdl_seq_GET(s, i));
|
||||
ADDOP_I(c, loc, COPY, 1);
|
||||
ADDOP(c, loc, TO_BOOL);
|
||||
ADDOP_JUMP(c, loc, jumpi, end);
|
||||
ADDOP(c, loc, POP_TOP);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue