title: Pdb go to a frame in exception within exception
body: <p>I am debugging a program named <code>a.py</code> using pdb</p>
  
  <pre><code>def f(x) :
      x / x
  
  def g(x) :
      try :
          f(x)
      except Exception as e :
          assert 0
  
  g(0)
  </code></pre>
  
  <p>When I run the program using <code>python3 -m pdb a.py</code>, the program stops at <code>assert 0</code> line, and I get the following error information:</p>
  
  <pre><code>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 "&lt;string&gt;", line 1, in &lt;module&gt;
    File "/tmp/a.py", line 11, in &lt;module&gt;
      g(0)
    File "/tmp/a.py", line 9, in g
      assert 0
  AssertionError
  </code></pre>
  
  <p>and the stack is (shown using <code>bt</code> command):</p>
  
  <pre><code>(Pdb) bt
    /usr/lib64/python3.6/pdb.py(1667)main()
  -&gt; pdb._runscript(mainpyfile)
    /usr/lib64/python3.6/pdb.py(1548)_runscript()
  -&gt; self.run(statement)
    /usr/lib64/python3.6/bdb.py(434)run()
  -&gt; exec(cmd, globals, locals)
    &lt;string&gt;(1)&lt;module&gt;()-&gt;None
    /tmp/a.py(11)&lt;module&gt;()-&gt;None
  -&gt; g(0)
  &gt; /tmp/a.py(9)g()
  -&gt; assert 0
  (Pdb) 
  </code></pre>
  
  <p>The problem is, I cannot go to function f to debug <code>x / x</code> simply using <code>up</code> and <code>down</code>, because my stack ends at the g function. </p>
  
  <p>How should I debug such exceptions within exceptions? What about exceptions within exceptions within exceptions ...?</p>