I'm trying to understand pdb.post_mortem(), and why the backtrace available in the debugger session seems limited.
I posted a similar question on stackoverflow[1], but figured I'd try here as well. Here's a simple program import pdb def inner(): raise Exception("bad stuff") def outer(): try: inner() except Exception as ex: pdb.post_mortem() # using breakpoint() gives the full stack trace, of course def main(): outer() main() When I run that, I get put in the debugger. Then, if I run the `bt` command to get a backtrace, I see: (Pdb) bt /path/to/script(10)outer() -> inner() > /path/to/script(6)inner() -> raise Exception("bad stuff") As you can see, the backtrace only has `outer()` and `inner()`. What happened to `main()`? I want the full stack available, so I can investigate variables, etc. at any point along the chain. (in a real example, there might be quite a lot of additional call frames of interest) For this contrived example, I can put `breakpoint()` instead of `post_mortem()`, and get what I want. But I feel like I'm misunderstanding post-mortem debugging. Is the full call stack simply not available? Note: I am aware that I can *print* the full stack trace (including `main()`), even if it takes some special effort. See these posts: * https://stackoverflow.com/questions/13210436/get-full-traceback/ * https://stackoverflow.com/questions/6086976/how-to-get-a-complete-exception-stack-trace-in-python ---- [1] https://stackoverflow.com/questions/58653016/get-full-backtrace-with-pdb-post-mortem -- https://mail.python.org/mailman/listinfo/python-list