python - Why doesn't `finally: return` propagate an unhandled exception? -
this question has answer here:
- python try-finally 1 answer
why function not raise exception? it's apparently not caught.
def f(): try: raise exception finally: return "ok" print(f()) # ok
this explicitly explained in the documentation:
if exception occurs in of clauses , not handled, exception temporarily saved.
finally
clause executed. [..] iffinally
clause executesreturn
orbreak
statement, the saved exception discarded
Comments
Post a Comment