This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mark.Shannon
Recipients Mark.Shannon, nedbat, pablogsal, serhiy.storchaka, xtreak
Date 2019-12-29.18:40:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577644850.22.0.619430805702.issue39114@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-12-29 18:40:50Mark.Shannonsetrecipients: + Mark.Shannon, nedbat, serhiy.storchaka, pablogsal, xtreak
2019-12-29 18:40:50Mark.Shannonsetmessageid: <1577644850.22.0.619430805702.issue39114@roundup.psfhosted.org>
2019-12-29 18:40:50Mark.Shannonlinkissue39114 messages
2019-12-29 18:40:50Mark.Shannoncreate