Skip to content

Commit ebf179d

Browse files
committed
Add test for disambiguated statements in pdb
1 parent 3968695 commit ebf179d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/test/test_pdb.py

+23
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,29 @@ def test_pdb_issue_gh_101517():
17981798
(Pdb) continue
17991799
"""
18001800

1801+
def test_pdb_issue_gh_104301():
1802+
"""See GH-104301
1803+
1804+
Make sure that ambiguous statements prefixed by '!' are properly disambiguated
1805+
1806+
>>> with PdbTestInput([
1807+
... '! n = 42', # disambiguated statement: reassign the name n
1808+
... 'n', # advance the debugger into the print()
1809+
... 'continue'
1810+
... ]):
1811+
... n = -1
1812+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1813+
... print(n)
1814+
> <doctest test.test_pdb.test_pdb_issue_gh_104301[0]>(8)<module>()
1815+
-> print(n)
1816+
(Pdb) ! n = 42
1817+
(Pdb) n
1818+
42
1819+
> <doctest test.test_pdb.test_pdb_issue_gh_104301[0]>(1)<module>()
1820+
-> with PdbTestInput([
1821+
(Pdb) continue
1822+
"""
1823+
18011824

18021825
@support.requires_subprocess()
18031826
class PdbTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)