If ones catches an exception outside of the function it is originally thrown, ones loses access to the local stack. As a result one cannot inspect the values of the variables th
If you want to wrap only some inner part of a function, or would need to decorate multiple functions otherwise, a context manager could be used as an alternative to the accepted answer. I am now using this simple version that catches all exceptions. I would also recommend using pudb
from contextlib import contextmanager
@contextmanager
def postmortem_pudb():
try:
yield
except Exception as exc:
pudb.post_mortem()
Use like this
with postmortem_pudb():
function_that_might_throw_some()
...
another_function_that_might_throw_some()
...
yet_another_function_that_might_throw_some()