Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6304d98

Browse files
gh-108463: Make expressions/statements work as expected in pdb (#108464)
1 parent7855d32 commit6304d98

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

‎Doc/library/pdb.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ change a variable or call a function. When an exception occurs in such a
252252
statement, the exception name is printed but the debugger's state is not
253253
changed.
254254

255+
..versionchanged::3.13
256+
Expressions/Statements whose prefix is a pdb command are now correctly
257+
identified and executed.
258+
255259
The debugger supports:ref:`aliases<debugger-aliases>`. Aliases can have
256260
parameters which allows one a certain level of adaptability to the context under
257261
examination.

‎Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ pdb
173173
the new ``exceptions [exc_number]`` command for Pdb. (Contributed by Matthias
174174
Bussonnier in:gh:`106676`.)
175175

176+
* Expressions/Statements whose prefix is a pdb command are now correctly
177+
identified and executed.
178+
(Contributed by Tian Gao in:gh:`108464`.)
179+
176180
sqlite3
177181
-------
178182

‎Lib/pdb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
237237
pass
238238
self.allow_kbdint=False
239239
self.nosigint=nosigint
240+
# Consider these characters as part of the command so when the users type
241+
# c.a or c['a'], it won't be recognized as a c(ontinue) command
242+
self.identchars=cmd.Cmd.identchars+'=.[](),"\'+-*/%@&|<>~^'
240243

241244
# Read ~/.pdbrc and ./.pdbrc
242245
self.rcLines= []

‎Lib/test/test_pdb.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,46 @@ def test_pdb_multiline_statement():
19571957
(Pdb) c
19581958
"""
19591959

1960+
deftest_pdb_show_attribute_and_item():
1961+
"""Test for multiline statement
1962+
1963+
>>> def test_function():
1964+
... n = lambda x: x
1965+
... c = {"a": 1}
1966+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1967+
... pass
1968+
1969+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
1970+
... 'c["a"]',
1971+
... 'c.get("a")',
1972+
... 'n(1)',
1973+
... 'j=1',
1974+
... 'j+1',
1975+
... 'r"a"',
1976+
... 'next(iter([1]))',
1977+
... 'list((0, 1))',
1978+
... 'c'
1979+
... ]):
1980+
... test_function()
1981+
> <doctest test.test_pdb.test_pdb_show_attribute_and_item[0]>(5)test_function()
1982+
-> pass
1983+
(Pdb) c["a"]
1984+
1
1985+
(Pdb) c.get("a")
1986+
1
1987+
(Pdb) n(1)
1988+
1
1989+
(Pdb) j=1
1990+
(Pdb) j+1
1991+
2
1992+
(Pdb) r"a"
1993+
'a'
1994+
(Pdb) next(iter([1]))
1995+
1
1996+
(Pdb) list((0, 1))
1997+
[0, 1]
1998+
(Pdb) c
1999+
"""
19602000

19612001
deftest_pdb_issue_20766():
19622002
"""Test for reference leaks when the SIGINT handler is set.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make expressions/statements work as expected in pdb

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp