[Python-Dev] Bug? Can't rebind local variables after calling pdb.set_trace()

Guido van Rossum guido at python.org
Tue Apr 12 23:02:09 CEST 2011


On Tue, Apr 12, 2011 at 1:05 PM, Lennart Regebro <regebro at gmail.com> wrote:
> Hasn't it always been like that? I tried with Python 2.3 now and it's
> the same. I have no memory of that actually changing an existing
> variable in any version of Python I've used. More testing turns out
> that this works:
>
> -> print "lv is ", lv
> (Pdb) lv=2
> (Pdb) c
> lv is  2
>
> While this seem to "reset" is:
>
> -> print "lv is ", lv
> (Pdb) lv=2
> (Pdb) lv
> 1
> (Pdb) c
> lv is  1
>
> This is the same from Python 2.3 to 2.6. I thought is just was a lack
> of feature, that there for some reason was really hard to change the
> value of an existing variable from the debugger. I though that for ten
> years. It never occurred to me to change the variable and type c
> without first checking that the variable had changed... :-)
>
> It is however fixed in 2.7.
>
> -> print "lv is ", lv
> (Pdb) lv=2
> (Pdb) lv
> 2
> (Pdb) c
> lv is  2
>
>
> But this bug/lack of feature has been there as long as I can remember. :-)

I swear it was my intention that assigning to locals would work, and I
was surprised to learn that it didn't. I'm glad it's fixed in 2.7
though... :-)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list