Mark Shannon <m...@hotpy.org> added the comment:
The issue here is: Is it legal to convert if x: pass into pass ? The explicit effect of the code is unchanged, BUT the implicit effect (of calling x.__bool__) is changed. The examples Serhiy gives are similar. If `bool(a)` evaluates to False, then `bool(a and b)` must be False, so we skip testing `a and b`. However, we do not know that `bool(a and b)` cannot have a side-effect, so the optimization could be incorrect w.r.t. side effects. ---------- title: Regression __bool__ if AttributeError is raised (Possible regression introduced by bpo-42615) -> Is it legal to eliminate tests of a value, when that test has no effect on control flow? _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42899> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com