title: Where can I see the amount of "extra recursion" stack kept for recovery from recursion limit?
body: <p>This question is about trying to understand python internals.</p>
  <p>Consider the code:</p>
  <pre><code>import sys
  
  sys.setrecursionlimit(100)
  
  def myfunc(n):
      print(n, sys.getrecursionlimit())
      try:
          myfunc(n+1)
      except Exception as e1:
          print('Cannot proceed')
          print(e1)
          try:
              myfunc(n+1)
          except Exception as e2:
              print('That went wrong')
              print(e2)
  
  myfunc(0)
  </code></pre>
  <p>Warning - This code is meant for python internal research and causes python to crush. Leads to actual <code>Fatal Python error: Cannot recover from stack overflow.</code>.</p>
  <p>This is the result:</p>
  <pre><code>....
  ....
  92 100
  93 100
  94 100
  95 100
  Cannot proceed
  maximum recursion depth exceeded while calling a Python object
  95 100
  96 100
  97 100
  98 100
  99 100
  100 100
  101 100
  102 100
  103 100
  104 100
  105 100
  106 100
  107 100
  108 100
  109 100
  110 100
  111 100
  112 100
  113 100
  114 100
  115 100
  116 100
  117 100
  118 100
  119 100
  120 100
  121 100
  122 100
  123 100
  124 100
  125 100
  126 100
  127 100
  128 100
  129 100
  130 100
  131 100
  132 100
  133 100
  134 100
  135 100
  136 100
  137 100
  138 100
  139 100
  140 100
  141 100
  142 100
  143 100
  144 100
  Fatal Python error: Cannot recover from stack overflow.
  
  Current thread 0x0000379c (most recent call first):
    File &quot;....test.py&quot;, line 7 in myfunc
    File &quot;....test.py&quot;, line 9 in myfunc
  ....
  ....
  </code></pre>
  <p>This is what I imagine roughly going on:</p>
  <ol>
  <li>The function counts up till close to 100 before hitting the recursion limit. Close to 100 and not 100 since some stack is used by python itself.</li>
  <li>When the exception occurs the actual recursion limit is set higher to allow recovery.</li>
  <li>Since my function insists on keep doing recursion it will hit the new limit after some time.</li>
  <li>But this time this &quot;extended limit&quot; recovery mechanism is exhausted and a fatal stack overflow occurs.</li>
  </ol>
  <p>Am I right?</p>
  <p>My question: Can I see the amount of &quot;extra recursion&quot; stack in some system variable, using something equivalent to <code>sys.getrecursionlimit()</code>?</p>