If an exception occurs in any of the clauses and is not handled, the exception is temporarily saved. The finally clause is executed. If there is a saved exception, it is re-raised at the end of the finally clause. If the finally clause raises another exception or executes a return or break statement, the saved exception is lost. The exception information is not available to the program during execution of the finally clause.
try:
1 / 0
except:
print 1
raise Exception('!!!')
finally:
print 2
Выдаёт:
1
2
Traceback (most recent call last):
File “<pyshell#14>”, line 5, in <module>
raise Exception('!!!')
Exception: !!!