10000 gh-101928: fix crash in compiler on multi-line lambda in function cal… · python/cpython@df7ccf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit df7ccf6

Browse files
authored
gh-101928: fix crash in compiler on multi-line lambda in function call (#101933)
1 parent 0b13575 commit df7ccf6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Lib/test/test_compile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,17 @@ def test_if_expression_expression_empty_block(self):
11551155
with self.subTest(expr=expr):
11561156
compile(expr, "<single>", "exec")
11571157

1158+
def test_multi_line_lambda_as_argument(self):
1159+
# See gh-101928
1160+
compile("""
1161+
def foo(param, lambda_exp):
1162+
pass
1163+
1164+
foo(param=0,
1165+
lambda_exp=lambda:
1166+
1)
1167+
""", "<test>", "exec")
1168+
11581169

11591170
@requires_debug_ranges()
11601171
class TestSourcePositions(unittest.TestCase):

Python/compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9085,8 +9085,8 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
90859085
Py_DECREF(cnt);
90869086
break;
90879087
case RETURN_VALUE:
9088-
INSTR_SET_OP1(inst, RETURN_CONST, oparg);
9089-
INSTR_SET_OP0(&bb->b_instr[i + 1], NOP);
9088+
INSTR_SET_OP0(inst, NOP);
9089+
INSTR_SET_OP1(&bb->b_instr[++i], RETURN_CONST, oparg);
90909090
break;
90919091
}
90929092
break;

0 commit comments

Comments
 (0)
0