miexp("malicious error") not processed, so the program terminates. On the other hand, the execution of the finally block is guaranteed.
So that this Python executes the finally block before actually throwing an exception. From the doc:
If an exception occurs in any of the sentences and is not processed, the exception is temporarily saved. The finally clause is executed. If there is a stored exception, it will be raised again at the end of the finally clause.
source share