[New-bugs-announce] [issue42899] Possible regression introduced by bpo-42615

Steve Stagg report at bugs.python.org
Mon Jan 11 17:26:53 EST 2021

New submission from Steve Stagg <stestagg at gmail.com>:

This was raised by Mats Wichmann <mats at 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()
   if b:
except AttributeError:

Before the change, the output is:

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:


It seems like the entire branch is being eliminated prematurely, but maybe only when the statement is wrapped in a try-except?

messages: 384867
nosy: Mark.Shannon, m, stestagg
priority: normal
severity: normal
status: open
title: Possible regression introduced by bpo-42615
type: behavior
versions: Python 3.10

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list