In Python, I have code that catches an exception, like this:
try:
<do stuff>
except:
exc_info = sys.exc_info()
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.
What is populating the f_locals structure? What might cause that local variables dictionary to be empty sometimes?