]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-151112: Move an `assert` that may fail in `cfg_builder_check` (GH-151153)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 11 Jun 2026 09:42:53 +0000 (11:42 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 09:42:53 +0000 (09:42 +0000)
(cherry picked from commit 2d3381035df24fbf512d897daa19a1040f7af3fd)

Co-authored-by: Stan Ulbrych <stan@python.org>
Python/flowgraph.c

index 2d710898913bfa4b359455c4c0f03dcbc0209ae0..5557f72fabac5a625e99b49909805c1d968dfee9 100644 (file)
@@ -392,7 +392,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) {
@@ -3662,6 +3661,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));