Hi everyone,
Should the optimizer eliminate tests that it can prove have no effect on
the control flow of the program, even if that may eliminate some side
effects in __bool__()?
For several years we have converted
if a and b:
...
to
if a:
if b:
...
which are equivalent, unless bool(a) has side effects the second time it
is called.
In master we convert `if x: pass` to `pass` which is equivalent, unless
bool(x) has side effects the first time it is called. This is a recent
change.
This is one of those "easy to fix, if we can decide on the semantics" bugs.
Submit your thoughts to https://bugs.python.org/issue42899, please.
Cheers,
Mark.
On 12/01/2021 12:45 am, Guido van Rossum wrote:
Ah never mind. Seems to be a real bug -- thanks for reporting!
On Mon, Jan 11, 2021 at 2:57 PM Mats Wichmann <m...@wichmann.us
<mailto:m...@wichmann.us>> wrote:
On 1/11/21 1:00 PM, Guido van Rossum wrote:
> All that said (I agree it's surprising that 3.10 seems backwards
> incompatible here) I would personally not raise AttributeError but
> TypeError in the `__bool__()` method.
eh, that was just me picking a cheap something to demo it. the program
raises an application-specific error that I didn't feel like
defining to
keep the repro as short as possible.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
<mailto:python-dev@python.org>
To unsubscribe send an email to python-dev-le...@python.org
<mailto:python-dev-le...@python.org>
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/SVGFN4DCDN462QVVMHY45IKH2XL4GVRD/
Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido van Rossum (python.org/~guido <http://python.org/~guido>)
/Pronouns: he/him //(why is my pronoun here?)/
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/BK4IUDXCZDDQCRSX3QGY7XUHOKMIDPG4/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/DFX7HMZ7RFUQJMJI7MABHKEK4EOYHR4A/
Code of Conduct: http://python.org/psf/codeofconduct/