Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-22577: in pdb, prevent changes to locals from being lost after a …
…jump
  • Loading branch information
scotchka committed Dec 9, 2018
commit 2a205b3f68d191fd41e876a32c9a8cf9e7998b2f
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def setup(self, f, tb):
# The f_locals dictionary is updated from the actual frame
# locals whenever the .f_locals accessor is called, so we
# cache it here to ensure that modifications are not overwritten.
self.curframe_locals = self.curframe.f_locals
self.curframe_locals = dict(self.curframe.f_locals)
return self.execRcLines()

# Can be executed earlier than 'setup' if desired
Expand Down
24 changes: 24 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,30 @@ def test_pdb_issue_20766():
pdb 2: <built-in function default_int_handler>
"""

def test_issue22577():
"""Test that local variable change not lost after jump.

>>> def test_function(x):
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
... lineno = 3
... lineno = 4

>>> with PdbTestInput(['x = 123',
... 'jump 4',
... 'x',
... 'continue']):
... test_function(1)
> <doctest test.test_pdb.test_issue22577[0]>(3)test_function()
-> lineno = 3
(Pdb) x = 123
(Pdb) jump 4
> <doctest test.test_pdb.test_issue22577[0]>(4)test_function()
-> lineno = 4
(Pdb) x
123
(Pdb) continue
"""


class PdbTestCase(unittest.TestCase):
def tearDown(self):
Expand Down