gh-104301: Allow leading whitespace in disambiguated pdb statements (#104342)

This commit is contained in:
James Gerity 2023-05-11 13:12:02 -04:00 committed by GitHub
parent 27419a71b5
commit 0449ffe3a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 12 deletions

View file

@ -1798,6 +1798,29 @@ def test_pdb_issue_gh_101517():
(Pdb) continue
"""
def test_pdb_ambiguous_statements():
"""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(f"The value of n is {n}")
> <doctest test.test_pdb.test_pdb_ambiguous_statements[0]>(8)<module>()
-> print(f"The value of n is {n}")
(Pdb) ! n = 42
(Pdb) n
The value of n is 42
> <doctest test.test_pdb.test_pdb_ambiguous_statements[0]>(1)<module>()
-> with PdbTestInput([
(Pdb) continue
"""
@support.requires_subprocess()
class PdbTestCase(unittest.TestCase):