From 77a644e0ef3b0c5ab9c00199341541ee87c1bbc1 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Fri, 12 Jan 2024 23:32:33 +0000 Subject: [PATCH 1/2] gh-107901: guarantee_lineno_for_exits is not doing anything --- Python/flowgraph.c | 49 ++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 4778f89e19b143..c22d99592a2235 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -504,6 +504,23 @@ no_redundant_jumps(cfg_builder *g) { return true; } +static bool +no_exits_without_lineno(basicblock *entryblock) { + for (basicblock *b = entryblock; b != NULL; b = b->b_next) { + cfg_instr *last = basicblock_last_instr(b); + if (last == NULL) { + continue; + } + if (last->i_loc.lineno < 0) { + if (last->i_opcode == RETURN_VALUE) { + assert(0); + return false; + } + } + } + return true; +} + #endif /***** CFG preprocessing (jump targets and exceptions) *****/ @@ -2368,40 +2385,12 @@ propagate_line_numbers(basicblock *entryblock) { } } -/* Make sure that all returns have a line number, even if early passes - * have failed to propagate a correct line number. - * The resulting line number may not be correct according to PEP 626, - * but should be "good enough", and no worse than in older versions. */ -static void -guarantee_lineno_for_exits(basicblock *entryblock, int firstlineno) { - int lineno = firstlineno; - assert(lineno > 0); - for (basicblock *b = entryblock; b != NULL; b = b->b_next) { - cfg_instr *last = basicblock_last_instr(b); - if (last == NULL) { - continue; - } - if (last->i_loc.lineno < 0) { - if (last->i_opcode == RETURN_VALUE) { - for (int i = 0; i < b->b_iused; i++) { - assert(b->b_instr[i].i_loc.lineno < 0); - - b->b_instr[i].i_loc.lineno = lineno; - } - } - } - else { - lineno = last->i_loc.lineno; - } - } -} - static int resolve_line_numbers(cfg_builder *g, int firstlineno) { - RETURN_IF_ERROR(duplicate_exits_without_lineno(g)); propagate_line_numbers(g->g_entryblock); - guarantee_lineno_for_exits(g->g_entryblock, firstlineno); + RETURN_IF_ERROR(duplicate_exits_without_lineno(g)); + assert(no_exits_without_lineno(g->g_entryblock)); return SUCCESS; } From 3045ae8e1d31371deff0e26e04679153db002f1b Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Mon, 15 Jan 2024 15:23:02 +0000 Subject: [PATCH 2/2] bump magic number --- Lib/importlib/_bootstrap_external.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 97858ee83f790f..8f63cd1d916f6b 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -479,7 +479,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3566).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3678).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c