Add basic try-finally testcase.
It's mildly suprising these work without further changes to exception handling code (the only change required was to handle SETUP_FINALLY).
This commit is contained in:
parent
8519342c1a
commit
c9887cbbe2
|
@ -0,0 +1,71 @@
|
||||||
|
print("noexc-finally")
|
||||||
|
try:
|
||||||
|
print("try")
|
||||||
|
finally:
|
||||||
|
print("finally")
|
||||||
|
|
||||||
|
print("noexc-finally-finally")
|
||||||
|
try:
|
||||||
|
print("try1")
|
||||||
|
try:
|
||||||
|
print("try2")
|
||||||
|
finally:
|
||||||
|
print("finally2")
|
||||||
|
finally:
|
||||||
|
print("finally1")
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("noexc-finally-func-finally")
|
||||||
|
def func2():
|
||||||
|
try:
|
||||||
|
print("try2")
|
||||||
|
finally:
|
||||||
|
print("finally2")
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("try1")
|
||||||
|
func2()
|
||||||
|
finally:
|
||||||
|
print("finally1")
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
print("exc-finally-except")
|
||||||
|
try:
|
||||||
|
print("try1")
|
||||||
|
try:
|
||||||
|
print("try2")
|
||||||
|
foo()
|
||||||
|
except:
|
||||||
|
print("except2")
|
||||||
|
finally:
|
||||||
|
print("finally1")
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("exc-finally-except-filter")
|
||||||
|
try:
|
||||||
|
print("try1")
|
||||||
|
try:
|
||||||
|
print("try2")
|
||||||
|
foo()
|
||||||
|
except NameError:
|
||||||
|
print("except2")
|
||||||
|
finally:
|
||||||
|
print("finally1")
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
print("exc-except-finally-finally")
|
||||||
|
try: # top-level catch-all except to not fail script
|
||||||
|
try:
|
||||||
|
print("try1")
|
||||||
|
try:
|
||||||
|
print("try2")
|
||||||
|
foo()
|
||||||
|
finally:
|
||||||
|
print("finally2")
|
||||||
|
finally:
|
||||||
|
print("finally1")
|
||||||
|
except:
|
||||||
|
print("catch-all except")
|
||||||
|
print()
|
Loading…
Reference in New Issue