[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
priority: high -> release blocker

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
priority: normal -> high

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Mark Shannon


Change by Mark Shannon :


--
assignee:  -> Mark.Shannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Steve Stagg


Steve Stagg  added the comment:

Apologies, script should have read:
class B:
 def __bool__(self):
 print("bool(B)")
 raise AttributeError("don't do that!")

b = B()
try:
   if b:
pass
except AttributeError:
   print("GOT ERROR")
   raise IndexError("Should GET THIS")

print("SHOULDN'T GET THIS")


---

The DIS before the change for this code is:
BEFORE:
  1   0 LOAD_BUILD_CLASS
  2 LOAD_CONST   0 (", line 1>)
  4 LOAD_CONST   1 ('B')
  6 MAKE_FUNCTION0
  8 LOAD_CONST   1 ('B')
 10 CALL_FUNCTION2
 12 STORE_NAME   0 (B)

  6  14 LOAD_NAME0 (B)
 16 CALL_FUNCTION0
 18 STORE_NAME   1 (b)

  7  20 SETUP_FINALLY8 (to 30)

  8  22 LOAD_NAME1 (b)
 24 POP_JUMP_IF_FALSE   26

  9 >>   26 POP_BLOCK
 28 JUMP_FORWARD30 (to 60)

 10 >>   30 DUP_TOP
 32 LOAD_NAME2 (AttributeError)
 34 JUMP_IF_NOT_EXC_MATCH58
 36 POP_TOP
 38 POP_TOP
 40 POP_TOP

 11  42 LOAD_NAME3 (print)
 44 LOAD_CONST   2 ('GOT ERROR')
 46 CALL_FUNCTION1
 48 POP_TOP

 12  50 LOAD_NAME4 (IndexError)
 52 LOAD_CONST   3 ('Should GET THIS')
 54 CALL_FUNCTION1
 56 RAISE_VARARGS1
>>   58 RERAISE

 14 >>   60 LOAD_NAME3 (print)
 62 LOAD_CONST   4 ("SHOULDN'T GET THIS")
 64 CALL_FUNCTION1
 66 POP_TOP
 68 LOAD_CONST   5 (None)
 70 RETURN_VALUE

Disassembly of ", line 1>:
  1   0 LOAD_NAME0 (__name__)
  2 STORE_NAME   1 (__module__)
  4 LOAD_CONST   0 ('B')
  6 STORE_NAME   2 (__qualname__)

  2   8 LOAD_CONST   1 (", line 2>)
 10 LOAD_CONST   2 ('B.__bool__')
 12 MAKE_FUNCTION0
 14 STORE_NAME   3 (__bool__)
 16 LOAD_CONST   3 (None)
 18 RETURN_VALUE

Disassembly of ", line 2>:
  3   0 LOAD_GLOBAL  0 (print)
  2 LOAD_CONST   1 ('bool(B)')
  4 CALL_FUNCTION1
  6 POP_TOP

  4   8 LOAD_GLOBAL  1 (AttributeError)
 10 LOAD_CONST   2 ("don't do that!")
 12 CALL_FUNCTION1
 14 RAISE_VARARGS1



Afterwards, tehre's a single change:

8 becomes:

8  22 LOAD_NAME1 (b)
 24 POP_TOP

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42899] Possible regression introduced by bpo-42615

2021-01-11 Thread Steve Stagg


New submission from Steve Stagg :

This was raised by Mats Wichmann   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 
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 
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?

--
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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com