title: Possible bug in pdb module in Python 3 when using list generators
body: <p>After running this code in Python 3: </p>
  
  <pre><code>import pdb
  
  def foo():
      nums = [1, 2, 3]
      a = 5
      pdb.set_trace()
  
  foo()
  </code></pre>
  
  <p>The following expressions work:</p>
  
  <pre><code>(Pdb) print(nums)
  [1, 2, 3]
  
  (Pdb) print(a)
  5
  
  (Pdb) [x for x in nums]
  [1, 2, 3]
  </code></pre>
  
  <p>but the following expression fails: </p>
  
  <pre><code>(Pdb) [x*a for x in nums]
  *** NameError: global name 'a' is not defined
  </code></pre>
  
  <p>The above works fine in Python 2.7.</p>
  
  <p>Is this a bug or I am missing something?</p>
  
  <p><strong>Update</strong>: See the new accepted answer. This was indeed a bug (or a problematic design) which has been addressed now by introducing a new command and mode in pdb.</p>