diff options
author | Damien George <damien.p.george@gmail.com> | 2018-09-03 17:41:02 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-03 17:41:02 +1000 |
commit | 3cd2c281d7cf990b3afb78287a58cf4ee3f23ca5 (patch) | |
tree | af1ec7ff9ae66946cf02c96f37c989979291ce18 /tests/basics/try_finally1.py | |
parent | b735208403a54774f9fd3d966f7c1a194c41870f (diff) |
py/emitnative: Cancel caught exception once handled to prevent reraise.
The native emitter keeps the current exception in a slot in its C stack
(instead of on its Python value stack), so when it catches an exception it
must explicitly clear that slot so the same exception is not reraised later
on.
Diffstat (limited to 'tests/basics/try_finally1.py')
-rw-r--r-- | tests/basics/try_finally1.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/basics/try_finally1.py b/tests/basics/try_finally1.py index 2416f6d18..1e821deb6 100644 --- a/tests/basics/try_finally1.py +++ b/tests/basics/try_finally1.py @@ -69,3 +69,16 @@ try: # top-level catch-all except to not fail script except: print("catch-all except") print() + +# case where a try-except within a finally cancels the exception +print("exc-finally-subexcept") +try: + print("try1") +finally: + try: + print("try2") + foo + except: + print("except2") + print("finally1") +print() |