summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--tests/basics/try_finally_loops.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/basics/try_finally_loops.py b/tests/basics/try_finally_loops.py
index 06a6b4a0ce..a4b80196fe 100644
--- a/tests/basics/try_finally_loops.py
+++ b/tests/basics/try_finally_loops.py
@@ -41,3 +41,28 @@ for i in [1]:
break
finally:
print('finally 4')
+
+# Test unwind-jump where there is nothing in the body of the try or finally.
+# This checks that the bytecode emitter allocates enough stack for the unwind.
+for i in [1]:
+ try:
+ break
+ finally:
+ pass
+
+# The following test checks that the globals dict is valid after a call to a
+# function that has an unwind jump.
+# There was a bug where an unwind jump would trash the globals dict upon return
+# from a function, because it used the Python-stack incorrectly.
+def f():
+ for i in [1]:
+ try:
+ break
+ finally:
+ pass
+def g():
+ global global_var
+ f()
+ print(global_var)
+global_var = 'global'
+g()