Issue577395

classification
Title: Outer finally not executed at return
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn
Priority: normal Keywords:

Created on 2002-07-04.12:45:54 by anonymous, last changed 2002-10-09.14:10:02 by bckfnn.

Messages
msg681 (view) Author: Nobody/Anonymous (nobody) Date: 2002-07-04.12:45:54
This program (also attached):

x = []
def trying():
    try:
        try:
            x.append(1)
            return
        finally:
            x.append(2)
    finally:
        x.append(3)

trying()
assert x == [1,2,3], repr(x)


outputs:

AssertionError: [1, 2]

Ie. the outer finally is not executed at return.


The workaround is simple: return after the last finally
and store an evt. return value in a temporary variable.
I did not experiment with raising exceptions instead
of returning.

In my case this bug caused a lock not to be released :)

Have fun,
Ype

ykingma@xs4all.nl
msg682 (view) Author: Finn Bock (bckfnn) Date: 2002-10-09.14:10:02
Logged In: YES 
user_id=4201

Fixed in CodeCompiler.java: 2.29 using patch supplied by Ype
Kingma.
History
Date User Action Args
2002-07-04 12:45:54anonymouscreate