[issue26072] pdb fails to access variables closed over
Chun-Yu Tseng
report at bugs.python.org
Wed Nov 16 05:53:37 EST 2016
Chun-Yu Tseng added the comment:
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.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26072>
_______________________________________
More information about the Python-bugs-list
mailing list