LionHeart123 / pyscripter

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

Inspection of variable gets the scope wrong #678

Closed GoogleCodeExporter closed 9 years ago

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

Run this program with debugging, put a break-point on the last line of the 
function.  Hover the cursor above the local and the global variables n. 

n = "Hello"

def f():
   n = 123
   return n

f()

What is the expected output? What do you see instead?
I expect the global n to have the value "Hello" and the local one to have the 
value 123.  Instead, PyScripter shows the global one as having the value 123.

What version of the product are you using? On what operating system?
PyScripter 2.5.3.0 x86 on Windows 7 (32 bit), Python 3.2.3.

Please provide any additional information below.
For teaching (which is what I am doing), this bug can lead to fundamental 
confusion in the minds of the students.

Original issue reported on code.google.com by cspwc...@gmail.com on 28 Jul 2012 at 10:59

GoogleCodeExporter commented 9 years ago
The debugger hint just evaluates the word under the cursor in the context of 
the current stack frame.

As per your instructions if you go to the Call Stack Window and select the top 
frame (last in the list) and hover again the cursor over 'n' (any 'n') you will 
see the value as "Hello".

So debugger hints do not do any scope analysis and in any case it would be very 
difficult to associate reliably different scopes with currently executing stack 
frames.

I understand the confusion in the minds of the students but I think that at 
some point they need to understand the concept of stack frames (Call stack 
window) and how they may or may not relate to code scopes.

Original comment by pyscripter on 16 Aug 2012 at 10:32