Author stestagg
Recipients Mark.Shannon, Mohamed_Atef, stestagg
Date 2021-01-11.22:26:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610404013.09.0.265713602389.issue42899@roundup.psfhosted.org>
In-reply-to
Content
This was raised by Mats Wichmann <mats@python.org>  on the python-dev list.

Commit : c71581c7a4192e6ba9a79eccc583aaadab300efa
bpo-42615: Delete redundant jump instructions that only bypass empty blocks (GH-23733)

appears to have changed the behaviour of the following code:

class B:
     def __bool__(self):
         raise AttributeError("don't do that!")

b = B()
try:
   if b:
        pass
except AttributeError:
   print("HI")


Before the change, the output is:

bool(B)
GOT ERROR
Traceback (most recent call last):
  File "../test.py", line 8, in <module>
    if b:
  File "../test.py", line 4, in __bool__
    raise AttributeError("don't do that!")
AttributeError: don't do that!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../test.py", line 12, in <module>
    raise IndexError("Should GET THIS")
IndexError: Should GET THIS


After the change, just:

SHOULDN'T GET THIS

It seems like the entire branch is being eliminated prematurely, but maybe only when the statement is wrapped in a try-except?
History
Date User Action Args
2021-01-11 22:26:53stestaggsetrecipients: + stestagg, Mark.Shannon, Mohamed_Atef
2021-01-11 22:26:53stestaggsetmessageid: <1610404013.09.0.265713602389.issue42899@roundup.psfhosted.org>
2021-01-11 22:26:53stestagglinkissue42899 messages
2021-01-11 22:26:52stestaggcreate