title: Why does my python program throw an error when running it with the debugger doesn't?
body: <p>First I run the following snippet of code in Pycharm using the play button:</p>
  
  <pre><code>import os
  import pickle
  import matplotlib.pyplot as plt
  import numpy as np
  
  directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), './linear_models')
  file_path = os.path.join(directory, '/factor_model/predict_car_prices.p')
  with open(file_path, 'rb') as f:
      lm = pickle.load(f)
  print("Cat")
  </code></pre>
  
  <p>It has the following traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/ben/Documents/programs/testload.py", line 9, in &lt;module&gt;
      lm = pickle.load(f)
    File "/usr/local/lib/python3.7/site-packages/statsmodels/base/data.py", line 105, in __setstate__
      return_type='dataframe')
    File "/usr/local/lib/python3.7/site-packages/patsy/highlevel.py", line 308, in dmatrices
      eval_env = EvalEnvironment.capture(eval_env, reference=1)
    File "/usr/local/lib/python3.7/site-packages/patsy/eval.py", line 226, in capture
      return cls([frame.f_locals, frame.f_globals],
  AttributeError: 'NoneType' object has no attribute 'f_locals'
  </code></pre>
  
  <p>If I run a debugger instead then the program finishes without reporting an error.</p>