◐ Shell
clean mode source ↗

Message 280933 - Python tracker

The last patch in #21161 fixes some problems but also brings up critical issues:

(Pdb) list .
  1      y = 2
  2
  3      def f():
  4          y = 9
  5          z = 10
  6  ->     import pdb; pdb.set_trace();
  7      f()
[EOF]
(Pdb) globals()['y']
9
(Pdb) global y; print(y)
9
(Pdb) globals()['z']
10

I think that we should not copy local variables to globals()  while doing execution. It will always bring out the wrong result of `globals()`.

So, the patch I proposed here is focused on "Showing Friendly Error Message" to let the users be less confused. 


# The patch works when a user tries to bound a free variable to a list comprehension. It will show the proper error message, too.