New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pdb go stack up/down #53842
Comments
Hello, with python 2.7 I encounter the following problem:
I have created the following sample script:
import pdb
def function_1(number):
stack_1 = number
function_2(stack_1)
def function_2(number):
stack_2 = number + 1
function_3(stack_2)
def function_3(number):
stack_3 = number + 1
pdb.set_trace()
print stack_3
function_1(1) This is what I have done in the pdb session:
I walked through the stack and changed the values of the variables stack_x but the values weren't saved when I moved one frame up/down |
Thank you for the report. I don’t know pdb much, but I assume you have checked the doc to make sure this is indeed a bug. Can you test it with 3.1 and 3.2 too? Bug tracker tip: You can find if a core developer is interested in a module in Misc/maintainers.rst and make them nosy (or assign to them, if there is a star near their name, like in Georg’s case). |
The problem here is that changes in the locals are only saved back to the frame when leaving the trace function, and up/down don't do that. This could be fixed by making Pdb.curframe_locals a dictionary for all visited frames while interaction is running. I'll look into it for 3.2. |
I believe this is slightly tricky because 'bdb.format_stack_entry' makes references to '.f_locals' and 'bdb.format_stack_entry' is invoked in several places in 'pdb'. One option would be to add a extra parameter to 'bdb.format_stack_entry' to accept a dictionary of locals to operate with. I implemented this approach and added a doctest to verify. See attached patch. I didn't update the 'bdb' documentation to note the new parameter, but will if this approach seems reasonable. |
It is not only the up and down commands; the where, longlist and In Markus sample script above, and with the patch applied, when the With a dictionary mapping frames to f_locals (and only updating this PyFrame_FastToLocals(frame);
result = PyEval_CallObject(callback, args);
PyFrame_LocalsToFast(frame, 1); Only the f_locals of the top level frame is saved by Another solution would be to ensure that changes made to locals at the |
Note that we're currently looking into this as something that could be potentially addressed by PEP-558 and any related changes to the way that function locals interact with trace hooks: https://bugs.python.org/issue30744#msg304388 |
I've reproduced the bug on 3.10. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: