Author nedbat
Recipients nedbat
Date 2018-09-16.13:15:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537103756.04.0.956365154283.issue34705@psf.upfronthosting.co.za>
In-reply-to
Content
When a return statement also executes a finally clause, the sequence of lines reported to the trace function is different in 3.8 than it has been before 3.8:

$ cat finally_trace.py
def return_from_finally():
    try:
        print("returning")
        return 17
    finally:
        print("finally")

def trace(frame, event, arg):
    print(frame.f_lineno, event)
    return trace

import sys
sys.settrace(trace)
return_from_finally()

$ python3.7 finally_trace.py
1 call
2 line
3 line
returning
4 line
6 line
finally
6 return

$ python3.8 finally_trace.py
1 call
2 line
3 line
returning
4 line
6 line
finally
4 line
4 return


Is this intentional? Is it a bug? Will it change back before 3.8 is shipped?
History
Date User Action Args
2018-09-16 13:15:56nedbatsetrecipients: + nedbat
2018-09-16 13:15:56nedbatsetmessageid: <1537103756.04.0.956365154283.issue34705@psf.upfronthosting.co.za>
2018-09-16 13:15:56nedbatlinkissue34705 messages
2018-09-16 13:15:55nedbatcreate