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
Switching frame will erase the local variable changes in pdb #102864
This issue is related to #101673 , where f_locals being accessed during the debugging clears the changes of local variables. We need to only do one access of f_locals before giving back control.
deff():
a=1breakpoint()
print(a)
f()
> /home/gaogaotiantian/programs/mycpython/example.py(4)f()
-> print(a)
(Pdb) p a
1
(Pdb) !a = 2
(Pdb) p a
2
(Pdb) u
> /home/gaogaotiantian/programs/mycpython/example.py(6)<module>()
-> f()
(Pdb) d
> /home/gaogaotiantian/programs/mycpython/example.py(4)f()
-> print(a)
(Pdb) p a
1
The worst part is, print_stack_entry calls format_stack_entry which is a bdb function, and it accesses f_locals. To keep the maximum compatibility of bdb, I decided to leave it alone and only fix pdb.
@iritkatriel could you take a look at the issue when you have some time as you reviewed the related one so you might already know the fundamental problem.
changed the title [-]Switching frame will erase the local variable changes[/-][+]Switching frame will erase the local variable changes in pdb[/+]on Mar 21, 2023
Unfortunately no. This issue has been there for a long time. As far as I can tell, you can repro it on 3.8. If I had to guess, it's probably when Python started using FAST instead of local variable dict.
Activity
gaogaotiantian commentedon Mar 21, 2023
@iritkatriel could you take a look at the issue when you have some time as you reviewed the related one so you might already know the fundamental problem.
[-]Switching frame will erase the local variable changes[/-][+]Switching frame will erase the local variable changes in pdb[/+]iritkatriel commentedon Mar 21, 2023
When was this issue introduced? Is it part of the 3.10/3.11 changes to frames?
gaogaotiantian commentedon Mar 21, 2023
Unfortunately no. This issue has been there for a long time. As far as I can tell, you can repro it on 3.8. If I had to guess, it's probably when Python started using FAST instead of local variable dict.
gaogaotiantian commentedon May 5, 2024
This is fixed by PEP 667.
gh-102864: Add switching frame test for pdb (#119564)
pythongh-102864: Add switching frame test for pdb (python#119564)