Message358998
Exammining the bytecode for:
def finally_return():
try:
return 14
finally:
a.append(16)
We have:
2 0 SETUP_FINALLY 16 (to 18)
3 2 POP_BLOCK
5 4 LOAD_GLOBAL 0 (a)
6 LOAD_METHOD 1 (append)
8 LOAD_CONST 1 (16)
10 CALL_METHOD 1
12 POP_TOP
3 14 LOAD_CONST 2 (14)
5 16 RETURN_VALUE
>> 18 LOAD_GLOBAL 0 (a)
20 LOAD_METHOD 1 (append)
22 LOAD_CONST 1 (16)
24 CALL_METHOD 1
26 POP_TOP
28 RERAISE
30 LOAD_CONST 0 (None)
32 RETURN_VALUE
Which looks correct, except for the line number of the first RETURN_VALUE.
Looking at the compiler it seems that we aren't preserving the original line number when emitting code for the finally block. |
|
Date |
User |
Action |
Args |
2019-12-29 18:40:50 | Mark.Shannon | set | recipients:
+ Mark.Shannon, nedbat, serhiy.storchaka, pablogsal, xtreak |
2019-12-29 18:40:50 | Mark.Shannon | set | messageid: <1577644850.22.0.619430805702.issue39114@roundup.psfhosted.org> |
2019-12-29 18:40:50 | Mark.Shannon | link | issue39114 messages |
2019-12-29 18:40:50 | Mark.Shannon | create | |
|