title: UnboundLocalError: local variable 'cur' referenced before assignment
body: <p>The following code throws the UnboundLocalError: </p>
  
  <pre><code>def fetch_results(conn, sql, **bind_params):
      """
      Immediately fetches the SQL results into memory
      Trades memory for the ability to immediately execute another query
      """
      global _log_func
      try:
          cur = conn.cursor()
          if _log_func:
              _log_func(cur, sql, bind_params)
  
          cur.execute(sql, bind_params)
          return cur.fetchall()
      finally:
          cur.close()
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>line 75, in fetch_results
      cur.close()
  UnboundLocalError: local variable 'cur' referenced before assignment
  </code></pre>
  
  <p>I am not sure why. Could anybody point me to the right direction?</p>