Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

question about pdb assignment statements

130 views
Skip to first unread message

Steve Ferg

unread,
Aug 16, 2010, 11:17:20 AM8/16/10
to
In this little script:

<pre>
import pdb
pdb.set_trace()
def main():
xm = 123
print("Hello,world!")
main()
</pre>

When I run this, I use pdb to step through it until I reach the point
in main() where the xm variable has been initialized, and then I try
to use pdb to reset the value of xm, and I can't.

Does anybody know why?

As I understand the documentation, http://docs.python.org/library/pdb.html
I *should* be able to do this.

[!]statement
Execute the (one-line) statement in the context of the current stack
frame.

Is there something about "in the context of the current stack frame"
that I don't understand? Or is it a bug (or a limitation) in pdb?

Kev Dwyer

unread,
Aug 16, 2010, 6:37:55 PM8/16/10
to pytho...@python.org

I think this may be the issue raised in bug 5215
(http://bugs.python.org/issue5215), committed in r71006. Displaying a
changed variable using the "p" command reverts the variable to its
previous value.

If you try

pdb.set_trace()
def main():
xm = 123
print("Hello,world!")

print xm

and change xm before it's printed (but do not display using "p")
it seems to work as expected.

Hope that helps,

Kev


Kev Dwyer

unread,
Aug 16, 2010, 6:39:58 PM8/16/10
to pytho...@python.org
On Mon, 16 Aug 2010 08:17:20 -0700, Steve Ferg wrote:

I should have added my version:

Python 2.6.2 (r262:71600, Jun 17 2010, 13:37:45)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2

Steve Ferg

unread,
Aug 17, 2010, 9:20:41 PM8/17/10
to
Thanks mucho!!
0 new messages