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.
This commit is contained in:
Damien George
2018-09-03 17:41:02 +10:00
parent b735208403
commit 3cd2c281d7
2 changed files with 16 additions and 1 deletions

View File

@@ -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()