A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/issues/102864 below:

Switching frame will erase the local variable changes in pdb · Issue #102864 · python/cpython · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4