try...finally is more powerful than I thought.
Ype Kingma
ykingma at accessforall.nl
Fri Nov 7 12:24:54 EST 2003
Jython once had a bug where it would not execute the outer finally
through a return, ie. in:
def x():
try:
try:
return 1
finally:
doSomething1()
finally:
doSomething2()
doSomething2() would not get executed.
The workaround was straightforward: save the return value in some local
variable and return at the end.
In case you like such puzzles, this is the test code:
http://cvs.sourceforge.net/viewcvs.py/jython/bugtests/test371.py?rev=1.2&view=markup
Btw. CPython never failed a single test case in there.
Have fun,
Ype
email at xs4all.nl
More information about the Python-list
mailing list