diff options
| author | Damien George <damien.p.george@gmail.com> | 2017-05-25 20:48:16 +1000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2017-05-25 20:48:16 +1000 |
| commit | 8b13cd7e19d8f7c8080baa6b3cc532bb6aa79c8a (patch) | |
| tree | 2636ff4a7aec2b0089031fb99d557b9375bd4cc8 /tests/basics/try_finally_loops.py | |
| parent | 8f064e469d551ab51a960cebf011e34af5e7fa58 (diff) | |
tests/basics: Add more tests for unwind jumps from within a try-finally.
These tests excercise cases that are fixed by the previous two commits.
Diffstat (limited to 'tests/basics/try_finally_loops.py')
| -rw-r--r-- | tests/basics/try_finally_loops.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/basics/try_finally_loops.py b/tests/basics/try_finally_loops.py index 06a6b4a0c..a4b80196f 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() |
