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.
def f():
a = 1
breakpoint()
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.
Linked PRs
This issue is related to #101673 , where
f_localsbeing accessed during the debugging clears the changes of local variables. We need to only do one access off_localsbefore giving back control.The worst part is,
print_stack_entrycallsformat_stack_entrywhich is abdbfunction, and it accessesf_locals. To keep the maximum compatibility ofbdb, I decided to leave it alone and only fixpdb.Linked PRs