Jeffrey Yasskin <jyass...@gmail.com> added the comment:

The assert seems confusing to me because it's overly specific. It causes
me to ask, "what's special about WHY_YIELD that why might be set to it?"
If I understand the loop correctly, we could rewrite the top as:

assert(why != WHY_YIELD);  /* These two values aren't handled in the
loop. */
assert(why != WHY_RERAISE);
orig_why = why;
while (why != WHY_NOT && f->f_iblock > 0) {
    /* The code does not change 'why' without breaking out of the loop. */
    assert(why == orig_why);
    ...
}

which would tell the reader more about the state of the world without
focusing their attention on anything that isn't somehow special.

Of course, nothing prevents the code from changing orig_why (*pines for
const and late declarations*), but such a change would be more obviously
wrong.

Was there another reason to assert(why!=WHY_YIELD) than that the if's
don't handle it? Is 'why' more likely to become WHY_YIELD than WHY_RERAISE?

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4888>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to