diff options
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index cfe4b6e..a71e7d3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8976,6 +8976,16 @@ error: return -1; } +static bool +basicblock_has_lineno(const basicblock *bb) { + for (int i = 0; i < bb->b_iused; i++) { + if (bb->b_instr[i].i_lineno > 0) { + return true; + } + } + return false; +} + /* If this block ends with an unconditional jump to an exit block, * then remove the jump and extend this block with the target. */ @@ -8992,6 +9002,10 @@ extend_block(basicblock *bb) { } if (last->i_target->b_exit && last->i_target->b_iused <= MAX_COPY_SIZE) { basicblock *to_copy = last->i_target; + if (basicblock_has_lineno(to_copy)) { + /* copy only blocks without line number (like implicit 'return None's) */ + return 0; + } last->i_opcode = NOP; for (int i = 0; i < to_copy->b_iused; i++) { int index = compiler_next_instr(bb); |