[Python-Dev] Needless assert in ceval.c?

skip at pobox.com skip at pobox.com
Fri Jan 9 05:53:53 CET 2009


I realize assert() is compiled out except in debug builds, but the assert in
the while loop following the fast_block_end label in ceval.c seems
misleading.  It looks like it should be hoisted out of the loop and only
checked before entering the loop.  There are no jumps into the loop.  why is
not assigned WHY_YIELD within the loop.  If you assert before the loop once
I think that will be sufficient and more clearly state the intent.

fast_block_end:
                assert(why != WHY_YIELD);  /* move the assert here */
                while (why != WHY_NOT && f->f_iblock > 0) {
                        PyTryBlock *b = PyFrame_BlockPop(f);

                        /* get rid of the assert here */
                        if (b->b_type == SETUP_LOOP && why == WHY_CONTINUE) {
                                ...
                        }
                        ...
                } /* unwind stack */

Reported to the tracker: http://bugs.python.org/issue4888

Skip


More information about the Python-Dev mailing list