title: exec statement in nested function make locals() empty?
body: <h2>First</h2>
  
  <pre><code>x = 30
  def out():
      x = 50
      def inner():
          print x
          print locals()
      return inner
  out()()    # print locals() output {'x': 50}
  </code></pre>
  
  <h2>Second</h2>
  
  <p>But when I use <code>exec</code> , the output of <code>print locals()</code> is empty</p>
  
  <pre><code>x =30
  def out():
      x = 50
      def inner():
          print x
          print locals()
          exec 'print x' in globals(), locals()
      return inner
  out()()    #  print locals() ouput {}
  </code></pre>
  
  <p>Does <code>exec</code> have any side effects to the output of <code>locals()</code> ?</p>