From 036de70a5811a7b330cc5c76d5bf9a62186f262b Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 11 Jun 2026 10:16:27 +0100 Subject: [PATCH] gh-151112: Move an `assert` that may fail in `cfg_builder_check` (GH-151153) (cherry picked from commit 2d3381035df24fbf512d897daa19a1040f7af3fd) Co-authored-by: Stan Ulbrych --- Python/flowgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/flowgraph.c b/Python/flowgraph.c index baba1f75b9cd43d..221d61364fd5a48 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -380,7 +380,6 @@ cfg_builder_maybe_start_new_block(cfg_builder *g) static bool cfg_builder_check(cfg_builder *g) { - assert(g->g_entryblock->b_iused > 0); for (basicblock *block = g->g_block_list; block != NULL; block = block->b_list) { assert(!_PyMem_IsPtrFreed(block)); if (block->b_instr != NULL) { @@ -2486,6 +2485,7 @@ _PyCfg_OptimizeCodeUnit(cfg_builder *g, PyObject *consts, PyObject *const_cache, int nlocals, int nparams, int firstlineno) { assert(cfg_builder_check(g)); + assert(g->g_entryblock->b_iused > 0); /** Preprocessing **/ /* Map labels to targets and mark exception handlers */ RETURN_IF_ERROR(translate_jump_labels_to_targets(g->g_entryblock));