python - Why doesn't `finally: return` propagate an unhandled exception? -


this question has answer here:

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. [..] if finally clause executes return or break statement, the saved exception discarded


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -