thecocce / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Code inspector displays values from wrong scope #398

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

x = 42
def g(x, y):
    print('x=%s and y=%s' % (x, y))

def f(prm):
    x = 3
    g(prm, x)

def main():
    arg = [20, 30, 40]
    f(arg)

What is the expected output? What do you see instead?

If I break this program on the print statement in g, 
there are three different instances of variable x in
this program, all in different scopes, all with different 
values.  But hovering over the global x, or the x in g, 
or the x in f all pop up the value associated with x in 
the local scope of g. 

What version of the product are you using? On what operating system?
PyScripter 2.1.1.0, Python 2.6.5 on Windows 7.

Please provide any additional information below.

Original issue reported on code.google.com by cspwc...@gmail.com on 30 Aug 2010 at 5:44

GoogleCodeExporter commented 9 years ago
All pyscripter is doing is evaluating the identifier under the cursor in the 
scope of the selected frame in the Call Stack.  The Call Stack frames which 
contain information about variable values do not necessarily relate to the 
scopes of the code and it would be hard to do anything more sophisticated here. 
So all PyScripter is doing is eval("x". frame.locals, frame.globals)

However PyScripter can help you, in your example, to see the values of all 3 x 
variables using debugger hints.  If say you break execution using a breakpoint 
inside the function g your call stack will will look like:

g
f
main
module

Debugger hint on x (any x) will show [20, 30, 40]
In the Call Stack Window click on f.
Debugger hint on x will show 3
In the Call Stack Window click on main.
Debugger hint on x will show 42

Original comment by pyscripter on 31 Aug 2010 at 11:20