From ebf179d3ef1ce2dc4dfb89d8cdb4a1a3f34335d0 Mon Sep 17 00:00:00 2001 From: James Gerity Date: Thu, 11 May 2023 11:02:28 -0400 Subject: [PATCH] Add test for disambiguated statements in pdb --- Lib/test/test_pdb.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 482c92dbf1f6a0..dfaff74588d4f7 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -1798,6 +1798,29 @@ def test_pdb_issue_gh_101517(): (Pdb) continue """ +def test_pdb_issue_gh_104301(): + """See GH-104301 + + Make sure that ambiguous statements prefixed by '!' are properly disambiguated + + >>> with PdbTestInput([ + ... '! n = 42', # disambiguated statement: reassign the name n + ... 'n', # advance the debugger into the print() + ... 'continue' + ... ]): + ... n = -1 + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... print(n) + > (8)() + -> print(n) + (Pdb) ! n = 42 + (Pdb) n + 42 + > (1)() + -> with PdbTestInput([ + (Pdb) continue + """ + @support.requires_subprocess() class PdbTestCase(unittest.TestCase):