title: Why does Python allow more recursion depth than the limit when running using IDLE's shell?
body: <p>Python seems to allow more recursion depth than the actual limit defined (default 1000, here it is 20 to make it easier), when the script is run using IDLE shell 3.9.1 (coding the script in IDLE and then pressing F5), on Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 (Windows 10 1909, build 18363.1316).</p>
  <p>With the code:</p>
  <pre class="lang-py prettyprint-override"><code>import sys, inspect
  sys.setrecursionlimit(20)
  print(&quot;Recursion limit:&quot;, sys.getrecursionlimit()) #ouputs 20
  
  recursionCounter = 0
  
  def recursive():
      global recursionCounter
      recursionCounter += 1
      print(&quot;stack:&quot;, len(inspect.stack())) #starts at 5 (IDLE is adding some nested loops) but stops at 36, higher than the recursion limit 
      recursive()
  
            
  try:
      recursive()
  except RecursionError:
      print(&quot;RecursionError raised. recursionCounter value is:&quot; , recursionCounter) #outputs 33
  
  </code></pre>
  <p>The full output is:</p>
  <pre><code>Recursion limit: 20
  stack: 5
  stack: 6
  stack: 7
  (...)
  stack: 35
  stack: 36
  RecursionError raised. recursionCounter value is: 33
  </code></pre>
  <p>Same thing with a lowered or increased limit, whatever the recursion limit is set to, Python goes deeper than it, exceeding it by the same amount (13 here).</p>
  <p>Is there something special with recursion limits or RecursionError that I missed and that can explain this effect?</p>