]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151112: Move an `assert` that may fail in `cfg_builder_check` (#151153)
authorStan Ulbrych <stan@python.org>
Thu, 11 Jun 2026 09:16:27 +0000 (10:16 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 09:16:27 +0000 (10:16 +0100)
Python/flowgraph.c

index 324a4fc1f10a68ec629273e2156cdb46d1d71ebe..f135f243c74e2f65063d08680cd52ac937390d17 100644 (file)
@@ -404,7 +404,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) {
@@ -3762,6 +3761,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));