https://github.com/python/cpython/commit/e3b94d8fa459502e411ec1d0366d17bdb7523c1c
commit: e3b94d8fa459502e411ec1d0366d17bdb7523c1c
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-11T09:46:04Z
summary:

[3.15] gh-151112: Move an `assert` that may fail in `cfg_builder_check` 
(GH-151153) (#151313)

(cherry picked from commit 2d3381035df24fbf512d897daa19a1040f7af3fd)

Co-authored-by: Stan Ulbrych <[email protected]>

files:
M Python/flowgraph.c

diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index b63906818e2d6cd..d9b8b2a3af402b5 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -403,7 +403,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) {
@@ -3756,6 +3755,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));

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to