-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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 loses local variable change after command longlist #101673
Comments
Hi all, it's been about a month since this issue is created. I think this issue is pretty straightforward and easy to reproduce. The fix in #101674 is easy to understand and well contained. Could someone give this issue/PR a review? Thanks. |
Any bugfix PR should include a unit test to prevent regressions. |
Hi @iritkatriel , thank you for the reminder! I've added the regression test for this bug - I confirmed that the test fails without the fix and passes with the fix. |
…ter longlist (pythonGH-101674) (cherry picked from commit 5d677c5) Co-authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
…ter longlist (python#101674) (cherry picked from commit 5d677c5)
Bug report
In pdb,
ll
will clear the local variable change.As you can tell,
a
was changed through!a = 2
but it was reverted afterll
.print(a)
also prints the unmodified value. Withoutll
, everything works fine.The reason lies in
getsourcelines
inpdb.py
. In that function, it tried to accessobj.f_locals
, which will refresh the dict withPyFrame_FastToLocalsWithError
as it's a property now.As a result, the local variable changes will be erased.
The original reason to check if
obj.f_globals is obj.f_locals
is to check whetherobj
is an module frame. Now that it has side effects to pdb, we can do the check with:It might not be the most delicate way, but I can't think of a situation where this won't work.
I did this change locally and I have confirmed:
./python -m test -j3
passedll
still prints the full file for module frameI'll make a PR soon and please let me know if there are any concerns about the fix.
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: