Python: sys.exc_info() is missing local variables
<p>In Python, I have code that catches an exception, like this:</p>

<pre><code>try:
    &lt;do stuff&gt;
except:
    exc_info = sys.exc_info()
</code></pre>

<p>The problem I'm running into is that the traceback object (exc_info[2]) is non-deterministically missing local variables in the traceback objects. I know this for a fact because I run the exact same code and sometimes the variables are in tb.tb_frame.f_locals and sometimes not. The global variables are always correct in tb.tb_frame.f_globals.</p>

<p>What is populating the f_locals structure? What might cause that local variables dictionary to be empty sometimes?</p>
