You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pdb loses local variable change after command longlist #101673
As you can tell, a was changed through !a = 2 but it was reverted after ll. print(a) also prints the unmodified value. Without ll, everything works fine.
The reason lies in getsourcelines in pdb.py. In that function, it tried to access obj.f_locals, which will refresh the dict with PyFrame_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 whether obj is an module frame. Now that it has side effects to pdb, we can do the check with:
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.
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.
Activity
gaogaotiantian commentedon Mar 5, 2023
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.
iritkatriel commentedon Mar 11, 2023
Any bugfix PR should include a unit test to prevent regressions.
gaogaotiantian commentedon Mar 12, 2023
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.
GH-101673: Fix pdb bug where local variable changes are lost after lo…
pythonGH-101673: Fix pdb bug where local variable changes are lost af…
pythonGH-101673: Fix pdb bug where local variable changes are lost af…
GH-101673: Fix pdb bug where local variable changes are lost after lo…
[3.10] GH-101673: Fix pdb bug where local variable changes are lost a…
pythonGH-101673: Fix pdb bug where local variable changes are lost af…