I am debugging a program named a.py using pdb def f(x) : x / x def g(x) : try : f(x) except Exception as e : assert 0 g(0) When I run the program using python3 -m pdb a.py, the program stops at assert 0 line, and I get the following error information: Traceback (most recent call last): File "/tmp/a.py", line 6, in g f(x) File "/tmp/a.py", line 2, in f x / x ZeroDivisionError: division by zero During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib64/python3.6/pdb.py", line 1667, in main pdb._runscript(mainpyfile) File "/usr/lib64/python3.6/pdb.py", line 1548, in _runscript self.run(statement) File "/usr/lib64/python3.6/bdb.py", line 434, in run exec(cmd, globals, locals) File "<string>", line 1, in <module> File "/tmp/a.py", line 11, in <module> g(0) File "/tmp/a.py", line 9, in g assert 0 AssertionError and the stack is (shown using bt command): (Pdb) bt /usr/lib64/python3.6/pdb.py(1667)main() -> pdb._runscript(mainpyfile) /usr/lib64/python3.6/pdb.py(1548)_runscript() -> self.run(statement) /usr/lib64/python3.6/bdb.py(434)run() -> exec(cmd, globals, locals) <string>(1)<module>()->None /tmp/a.py(11)<module>()->None -> g(0) > /tmp/a.py(9)g() -> assert 0 (Pdb) The problem is, I cannot go to function f to debug x / x simply using up and down, because my stack ends at the g function. How should I debug such exceptions within exceptions? What about exceptions within exceptions within exceptions ...? Continue reading...